Elixir XDR v0.1.1 XDR.Size View Source

Size utilities for various types

Link to this section Summary

Types

t()

Non-negative, unsigned, 32-bit integers are used for sizes of various types, like opaque and array

Functions

Pull out the first 4 bytes of the input binary and decode it as an integer size.

Encode the size in a 32-byte binary

The largest size available for sized types like array and opaque

Link to this section Types

Non-negative, unsigned, 32-bit integers are used for sizes of various types, like opaque and array

Link to this section Functions

Link to this function

decode!(encoding)

View Source
decode!(<<_::32, _::_*8>>) :: {t(), binary()}

Pull out the first 4 bytes of the input binary and decode it as an integer size.

Return the size and remaining binary in a tuple

iex> XDR.Size.decode!(<<0, 0, 1, 1>> <> "Hello")
{0x00000101, "Hello"}

Encode the size in a 32-byte binary

iex> XDR.Size.encode(0x00000101)
<<0, 0, 1, 1>>

The largest size available for sized types like array and opaque