xdr v0.1.2 XDR.Type.Union View Source

RFC 4506, Section 4.15 - Discriminated Union

Link to this section Summary

Functions

Decodes an XDR binary into a discriminant or {discriminant, value} tuple

Encodes a discriminant or {discriminant, value} tuple into an XDR binary

Determines if the discriminant (and if provided, the optional val) can be encoded into a valid union

Link to this section Types

Link to this type attributes() View Source
attributes() :: [{atom(), switch()}]
Link to this type cases() View Source
cases() :: [{discriminant(), val :: switch() | XDR.Type.Void | atom()}]
Link to this type spec() View Source
spec() :: [switch: switch(), cases: cases(), default: switch(), attributes: attributes()]
Link to this type switch() View Source
switch() ::
  XDR.Type.Int |
  XDR.Type.Uint |
  XDR.Type.Enum |
  XDR.Type.Bool |
  module()

Link to this section Functions

Link to this function decode(arg, spec) View Source
decode(xdr :: xdr(), spec :: spec()) ::
  {:ok, {discriminant :: t(), rest :: XDR.Type.Base.xdr()}} |
  {:error, reason :: :invalid}

Decodes an XDR binary into a discriminant or {discriminant, value} tuple

Link to this function encode(discriminant, spec) View Source
encode(discriminant :: t(), spec :: spec()) ::
  {:ok, xdr :: xdr()} |
  {:error, reason :: :invalid}

Encodes a discriminant or {discriminant, value} tuple into an XDR binary

Link to this function new(discriminant, spec) View Source
new(discriminant :: t(), spec :: spec()) ::
  {:ok, discriminant :: t()} |
  {:error, reason :: :invalid}
Link to this function valid?(discriminant, spec) View Source
valid?(discriminant :: t(), spec :: spec()) :: boolean()

Determines if the discriminant (and if provided, the optional val) can be encoded into a valid union