dbux v1.0.1 DBux.Protocol
Summary
Functions
Marshalls given list of values using given endianness
Unmarshalls given bitstring while interpreting data using given endianness
and signature (where signature comes in as nested list of types, such as
one generated by DBux.Type.type_from_signature/1
)
Types
endianness :: :little_endian | :big_endian
Functions
Specs
marshall_bitstring(DBux.Value.list_of_values, endianness) :: {:ok, {Bitstring, String.t}}
Marshalls given list of values using given endianness.
It returns {:ok, {bitstring, signature}}
.
It applies padding between values if they require some alignment.
Specs
unmarshall_bitstring(Bitstring, endianness, String.t, boolean) ::
{:ok, DBux.Value.list_of_values, Bitstring} |
{:error, any}
unmarshall_bitstring(Bitstring, endianness, DBux.Type.list_of_types, boolean) ::
{:ok, DBux.Value.list_of_values, Bitstring} |
{:error, any}
Unmarshalls given bitstring while interpreting data using given endianness
and signature (where signature comes in as nested list of types, such as
one generated by DBux.Type.type_from_signature/1
).
It handles padding between values if they require some alignment.
It returns {:ok, {list_of_values, rest}}
on success.
If unwrap_values
is false
, list_of_values
will contain a nested list of
DBux.Value
structs, otherwise it will contain plain values.
For example, signature “i(ss)” will map to the following result:
[%DBux.Value{type: :int32, value: 123},
%DBux.Value{type: :struct, value: [
%DBux.Value{type: :string, value: "sample1"},
%DBux.Value{type: :string, value: "sample2"}]]
if unwrap_values is set to false
, but it will map to:
[123, {"sample1", "sample2"}]
if it is set to true
.
rest
will contain remaining part of the bitstring.
It returns {:error, reason}
in case of failure.
Specifically, it returns {:error, :bitstring_too_short}
if given bitstring
was not long enough.