Rebus.Signature (rebus v0.3.0)
View SourceParses D-Bus type signatures into structured Elixir type descriptions.
Signature grammar violations are reported as :invalid_signature. Container
nesting is a local resource and safety cap; a grammatically valid signature
that exceeds it is reported as :resource_limit (or raises
Rebus.ResourceLimitError from parse!/1).
Summary
Functions
Parses a D-Bus signature into one AST node per top-level type.
Parses a D-Bus signature and raises when it is invalid.
Types
@type ast() :: {:byte | :boolean | :int16 | :uint16 | :int32 | :uint32 | :int64 | :uint64 | :double | :string | :object_path | :signature | :variant | :unix_fd, nil} | {:array, ast()} | {:struct, [ast()]} | {:dict_entry, ast(), ast()}
A parsed D-Bus type.
Basic types are {name, nil}. Containers retain their element or field
types: {:array, type}, {:struct, fields}, and
{:dict_entry, key_type, value_type}. A variant is {:variant, nil} because
its contained signature is carried in each encoded value.
Functions
Parses a D-Bus signature into one AST node per top-level type.
Returns {:error, :invalid_signature} for malformed or over-long input and
{:error, :resource_limit} when container nesting exceeds Rebus's local
limit.
Examples
iex> Rebus.Signature.parse("sa{sv}")
{:ok, [
{:string, nil},
{:array, {:dict_entry, {:string, nil}, {:variant, nil}}}
]}
iex> Rebus.Signature.parse("(")
{:error, :invalid_signature}
Parses a D-Bus signature and raises when it is invalid.
Raises ArgumentError for invalid input and Rebus.ResourceLimitError when
the nesting limit is exceeded.
Example
iex> Rebus.Signature.parse!("a{si}")
[{:array, {:dict_entry, {:string, nil}, {:int32, nil}}}]