dbux v1.0.0 DBux.Message

Summary

Functions

Creates DBux.Message with attributes appropriate for error

Creates DBux.Message with attributes appropriate for method call

Creates DBux.Message with attributes appropriate for method return

Creates DBux.Message with attributes appropriate for signal

Serializes DBux.Message into bitstream using given endianness

Parses bitstream into DBux.Message

Types

message_type ::
  :method_call |
  :method_return |
  :error |
  :signal
t :: %DBux.Message{body: DBux.Value.list_of_values, destination: String.t, error_name: String.t, flags: number, interface: String.t, member: String.t, message_type: message_type, path: String.t, reply_serial: number, sender: String.t, serial: DBux.Serial.t, signature: String.t, unix_fds: number}

Functions

build_error(reply_serial, error_name, destination, body \\ [], serial \\ 0)

Creates DBux.Message with attributes appropriate for error.

build_method_call(path, interface, member, body \\ [], destination \\ nil, serial \\ 0)

Creates DBux.Message with attributes appropriate for method call.

build_method_return(reply_serial, destination, body \\ [], serial \\ 0)

Creates DBux.Message with attributes appropriate for method return.

build_signal(path, interface, member, body \\ [], serial \\ 0)

Specs

build_signal(String.t, String.t, String.t, DBux.Value.list_of_values, DBux.Serial.t) :: %DBux.Message{body: term, destination: term, error_name: term, flags: term, interface: term, member: term, message_type: term, path: term, reply_serial: term, sender: term, serial: term, signature: term, unix_fds: term}

Creates DBux.Message with attributes appropriate for signal.

marshall(message, endianness \\ :little_endian)

Specs

marshall(%DBux.Message{body: term, destination: term, error_name: term, flags: term, interface: term, member: term, message_type: term, path: term, reply_serial: term, sender: term, serial: term, signature: term, unix_fds: term}, :little_endian | :big_endian) :: Bitstring

Serializes DBux.Message into bitstream using given endianness.

TODO describe return values

unmarshall(bitstring, unwrap_values)

Specs

unmarshall(Bitstring, boolean) ::
  {:ok, %DBux.Message{body: term, destination: term, error_name: term, flags: term, interface: term, member: term, message_type: term, path: term, reply_serial: term, sender: term, serial: term, signature: term, unix_fds: term}, Bitstring} |
  {:error, any}

Parses bitstream into DBux.Message.

First byte of the bitstream must be first byte of a message.

Returns {:ok, message, rest} in case of success, where message is a DBux.Message and rest is a remaining part of the given bitstream.

If not enough data was given it returns {:error, :bitstring_too_short}.