Combine.Parsers.Binary
This module defines common raw binary parsers, i.e. bits, bytes, uint, etc.
To use them, just add import Combine.Parsers.Binary
to your module, or
reference them directly.
All of these parsers operate on, and return bitstrings as their results.
Summary
Functions
This parser parses N bits from the input
This parser parses N bytes from the input
This parser parses a n-bit floating point number from the input
This parser parses a signed, n-bit integer from the input with the given endianness
This parser parses an unsigned, n-bit integer from the input with the given endianness
Types
Functions
Specs
bits(pos_integer) :: parser
This parser parses N bits from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse("Hi", bits(8))
["H"]
...> Combine.parse("Hi", bits(8) |> bits(8))
["H", "i"]
Specs
bytes(pos_integer) :: parser
This parser parses N bytes from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse("Hi", bytes(1))
["H"]
...> Combine.parse("Hi", bytes(1) |> bytes(1))
["H", "i"]
Specs
float(32 | 64) :: parser
This parser parses a n-bit floating point number from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<2.50::float-size(32)>>, float(32))
[2.5]
Specs
int(pos_integer, :be | :le) :: parser
This parser parses a signed, n-bit integer from the input with the given endianness.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<-85::big-signed-size(16),"-90"::binary>>, int(16, :be))
[-85]
Specs
uint(pos_integer, :be | :le) :: parser
This parser parses an unsigned, n-bit integer from the input with the given endianness.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<85::big-unsigned-size(16), "-90"::binary>>, uint(16, :be))
[85]