elephant v0.2.1 Elephant.Message View Source
Representation of sent or received messages.
Each message has three components:
- command
- list of headers
- body
The command is an atom and only commands specified in the STOMP specification
are allowed. Each header is a 2-tuple {"header-key", "header-value"}
. The
body is a binary.
Link to this section Summary
Functions
Get header by key
Checks if a header exists, by both key and value
Splits a string into two at the first zero-byte
Removes CR / CRLF at the beginning of the string
Link to this section Functions
Get header by key.
Returns {:ok, value}
or {:error, :notfound}
if the header does not exist.
Checks if a header exists, by both key and value.
Splits a string into two at the first zero-byte.
Examples
iex> Elephant.Message.read_until_zero(<<65, 66, 0, 67, 68>>)
{"AB", "CD"}
iex> Elephant.Message.read_until_zero(<<65, 66, 0>>)
{"AB", ""}
iex> Elephant.Message.read_until_zero(<<0, 67, 68>>)
{"", "CD"}
iex> Elephant.Message.read_until_zero(<<65, 66>>)
{"AB", ""}