1.0.0 • Published 1 year ago

d-bus-type-system v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

D-Bus type system

A TypeScript implementation of the D-Bus type system.

Installation

npm install d-bus-type-system

Features

  • Designed from the ground up with TypeScript.
  • 100% test coverage.
  • No npm runtime dependencies.
  • Accurate implementation of the D-Bus specification.

Usage example

Marshal a hello message

import {
  BufferWriter,
  arrayType,
  marshal,
  objectPathType,
  stringType,
  structType,
  uint32Type,
  uint8Type,
  variantType,
} from 'd-bus-type-system';

const wireFormatWriter = new BufferWriter({littleEndian: true});

const type = structType(
  uint8Type,
  uint8Type,
  uint8Type,
  uint8Type,
  uint32Type,
  uint32Type,
  arrayType(structType(uint8Type, variantType)),
);

marshal(wireFormatWriter, type, [
  `l`.charCodeAt(0), // endianness
  1, // message type: method call
  0, // flags
  1, // major protocol version
  0, // message body length
  1, // serial
  [
    [1, [objectPathType, `/org/freedesktop/DBus`]], // object path
    [2, [stringType, `org.freedesktop.DBus`]], // interface name
    [3, [stringType, `Hello`]], // member name
    [6, [stringType, `org.freedesktop.DBus`]], // destination
  ],
]);

wireFormatWriter.align(8);

console.log(wireFormatWriter.buffer);
6c 01 00 01  00 00 00 00  01 00 00 00  6d 00 00 00
01 01 6f 00  15 00 00 00  2f 6f 72 67  2f 66 72 65
65 64 65 73  6b 74 6f 70  2f 44 42 75  73 00 00 00
02 01 73 00  14 00 00 00  6f 72 67 2e  66 72 65 65
64 65 73 6b  74 6f 70 2e  44 42 75 73  00 00 00 00
03 01 73 00  05 00 00 00  48 65 6c 6c  6f 00 00 00
06 01 73 00  14 00 00 00  6f 72 67 2e  66 72 65 65
64 65 73 6b  74 6f 70 2e  44 42 75 73  00 00 00 00

Unmarshal a hello message

import {BufferReader, unmarshal} from 'd-bus-type-system';

const wireFormatReader = new BufferReader(wireFormatWriter.buffer, {
  littleEndian: true,
});

const value = unmarshal(wireFormatReader, type);
1.0.0

1 year ago

0.12.0

3 years ago

0.13.0

3 years ago

0.12.1

3 years ago

0.14.0

3 years ago

0.13.1

3 years ago

0.12.2

3 years ago

0.10.0

3 years ago

0.11.0

3 years ago

0.9.0

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.3.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago