gmsg

Types

pub type DecodeError {
  UnableToParse(String)
  UnableToDecode(String)
  UnsupportedDecode
  Truncated
}

Constructors

  • UnableToParse(String)
  • UnableToDecode(String)
  • UnsupportedDecode
  • Truncated
pub type EncodeError {
  UnsupportedEncode(String)
  Overflow(String)
  Internal(String)
}

Constructors

  • UnsupportedEncode(String)
  • Overflow(String)
  • Internal(String)

Represents all possible values in the MessagePack serialization format.

This type is used as an intermediate representation for converting between user-defined types and serialized binary data.

Variants

  • Nil: Represents a null or absent value.
  • Bool: Represents a true or false boolean value.
  • Int: Represents a signed or unsigned integer.
  • Float: Represents a 64-bit floating-point value.
  • String: Represents a UTF-8 encoded text string.
  • Binary: Represents raw binary data using a flat BitArray.
  • BinaryTree: Represents binary data using a structured BytesTree, which is more efficient for streaming and incremental construction.
  • Array: Represents a list of MsgPack values.
  • Map: Represents key-value pairs of MsgPack values.
  • Extended: Represents an extension type with a type tag and payload.

Notes

  • BinaryTree is preferred when constructing messages incrementally.
  • Extended corresponds to MsgPack’s “ext” type, which is used to encode application-defined data formats.
  • Keys in Map can be any MsgPack value, not just strings.
pub type MsgPack {
  MsgNil
  MsgBool(Bool)
  MsgInt(Int)
  MsgFloat(Float)
  MsgString(String)
  MsgBinary(BitArray)
  MsgArray(List(MsgPack))
  MsgMap(List(#(MsgPack, MsgPack)))
}

Constructors

  • MsgNil

    Represents a null or absent value.

  • MsgBool(Bool)

    Boolean value: true or false.

  • MsgInt(Int)

    Integer value (signed or unsigned).

  • MsgFloat(Float)

    64-bit floating-point value.

  • MsgString(String)

    UTF-8 string value.

  • MsgBinary(BitArray)

    Raw binary data as a flat BitArray.

  • MsgArray(List(MsgPack))

    Ordered list of MsgPack values.

  • MsgMap(List(#(MsgPack, MsgPack)))

    Map of MsgPack keys to MsgPack values.

Values

pub fn decode_msgpack_from_bit_offset(
  bits: BitArray,
  offset: Int,
) -> Result(#(MsgPack, Int), DecodeError)

Decode one MsgPack value that begins offset bits into bits. Returns the value and the bit-offset immediately after it.

pub fn encode(mp: MsgPack) -> Result(BitArray, EncodeError)
pub fn parse(
  from bits: BitArray,
  using decoder: decode.Decoder(t),
) -> Result(t, DecodeError)
Search Document