xdr v0.1.1 XDR.Type.Base behaviour View Source

Base behaviour for XDR type modules

Link to this section Summary

Callbacks

Decodes an XDR binary to a native type, also returns any un-decoded binary

Encodes a native type to an XDR binary

Returns the expected length (in bytes) of an XDR-encoded binary of this type (sans padding)

Returns the input if it’s a valid XDR module native type, or the default valid native type

Determines if a value is a valid XDR type

Link to this section Types

Link to this type error() View Source
error() :: atom() | String.t()
Link to this type xdr() View Source
xdr() :: <<_::_*32>>

Link to this section Callbacks

Link to this callback decode(xdr) View Source
decode(xdr :: xdr()) ::
  {:ok, {native :: t(), rest :: xdr()}} |
  {:error, reason :: error()}

Decodes an XDR binary to a native type, also returns any un-decoded binary

Link to this callback encode(native) View Source
encode(native :: t()) ::
  {:ok, xdr :: xdr()} |
  {:error, reason :: error()}

Encodes a native type to an XDR binary

Link to this callback length() View Source (optional)
length() :: non_neg_integer() | :struct | :union | :variable

Returns the expected length (in bytes) of an XDR-encoded binary of this type (sans padding)

Link to this callback new(native) View Source (optional)
new(native :: t()) ::
  {:ok, native :: t()} |
  {:error, reason :: error()}

Returns the input if it’s a valid XDR module native type, or the default valid native type

Link to this callback valid?(native) View Source
valid?(native :: t()) :: boolean()

Determines if a value is a valid XDR type