Skip to content

MessagePackEncoder

[Source]

Implements low-level encoding into the MessagePack serialization format.

You should be familiar with how MessagePack encodes messages if you use this API directly. There are very few guardrails preventing you from creating invalid documents. This is particularly true when using the array and map format family encoding methods.

primitive val MessagePackEncoder

Constructors

create

[Source]

new val create()
: MessagePackEncoder val^

Returns


Public Functions

nil

[Source]

nil format stores nil in 1 byte.

fun box nil(
  b: Writer ref)
: None val

Parameters

Returns


bool

[Source]

bool format family stores false or true in 1 byte.

fun box bool(
  b: Writer ref,
  t_or_f: Bool val)
: None val

Parameters

Returns


positive_fixint

[Source]

positive fixnum stores 7-bit positive integer.

  • Max value that can be encoded is 127.

Attemping to encode an out of range value will result in an error.

fun box positive_fixint(
  b: Writer ref,
  v: U8 val)
: None val ?

Parameters

Returns


negative_fixint

[Source]

negative fixnum stores 5-bit negative integer.

  • Max value that can be encoded is -1.
  • Min value that can be encoded is -32.

Attemping to encode an out of range value will result in an error.

fun box negative_fixint(
  b: Writer ref,
  v: I8 val)
: None val ?

Parameters

Returns


uint_8

[Source]

uint 8 stores a 8-bit unsigned integer.

fun box uint_8(
  b: Writer ref,
  v: U8 val)
: None val

Parameters

Returns


uint_16

[Source]

uint 16 stores a 16-bit big-endian unsigned integer.

fun box uint_16(
  b: Writer ref,
  v: U16 val)
: None val

Parameters

Returns


uint_32

[Source]

uint 32 stores a 32-bit big-endian unsigned integer.

fun box uint_32(
  b: Writer ref,
  v: U32 val)
: None val

Parameters

Returns


uint_64

[Source]

uint 64 stores a 64-bit big-endian unsigned integer.

fun box uint_64(
  b: Writer ref,
  v: U64 val)
: None val

Parameters

Returns


int_8

[Source]

int 8 stores a 8-bit signed integer.

fun box int_8(
  b: Writer ref,
  v: I8 val)
: None val

Parameters

Returns


int_16

[Source]

int 16 stores a 16-bit big-endian signed integer.

fun box int_16(
  b: Writer ref,
  v: I16 val)
: None val

Parameters

Returns


int_32

[Source]

int 32 stores a 32-bit big-endian signed integer.

fun box int_32(
  b: Writer ref,
  v: I32 val)
: None val

Parameters

Returns


int_64

[Source]

int 64 stores a 64-bit big-endian signed integer.

fun box int_64(
  b: Writer ref,
  v: I64 val)
: None val

Parameters

Returns


float_32

[Source]

float 32 stores a floating point number in IEEE 754 single precision floating point number format.

fun box float_32(
  b: Writer ref,
  v: F32 val)
: None val

Parameters

Returns


float_64

[Source]

float 64 stores a floating point number in IEEE 754 double precision floating point number format.

fun box float_64(
  b: Writer ref,
  v: F64 val)
: None val

Parameters

Returns


fixstr

[Source]

fixstr stores a byte array whose length is upto 31 bytes.

Attempting to encode a ByteSeq larger than 31 bytes will result in an error.

fun box fixstr(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


str_8

[Source]

str 8 stores a byte array whose length is upto (2^8)-1 bytes.

Attempting to encode a ByteSeq larger than (2^8)-1 bytes will result in an error.

fun box str_8(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


str_16

[Source]

str 16 stores a byte array whose length is upto (2^16)-1 bytes.

Attempting to encode a ByteSeq larger than (2^16)-1 bytes will result in an error.

fun box str_16(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


str_32

[Source]

str 32 stores a byte array whose length is upto (2^32)-1.

Attempting to encode a ByteSeq larger than (2^32)-1 bytes will result in an error.

fun box str_32(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


bin_8

[Source]

bin 8 stores a byte array whose length is upto (2^8)-1 bytes.

Attempting to encode a ByteSeq larger than (2^8)-1 bytes will result in an error.

fun box bin_8(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


bin_16

[Source]

bin 16 stores a byte array whose length is upto (2^16)-1 bytes.

Attempting to encode a ByteSeq larger than (2^16)-1 bytes will result in an error.

fun box bin_16(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


bin_32

[Source]

bin 32 stores a byte array whose length is upto (2^32)-1 bytes.

Attempting to encode a ByteSeq larger than (2^32)-1 bytes will result in an error.

fun box bin_32(
  b: Writer ref,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


fixarray

[Source]

Creates a header for a MessagePack "fixarray". This only creates the header. s number of array items should be written via other methods after this is called.

fixarray stores an array whose length is upto 15 elements.

Attempting to encode a value larger than 15 will result in an error.

fun box fixarray(
  b: Writer ref,
  s: U8 val)
: None val ?

Parameters

Returns


array_16

[Source]

Creates a header for a MessagePack "array_16". This only creates the header. s number of array items should be written via other methods after this is called.

array 16 stores an array whose length is upto (2^16)-1 elements.

Attempting to encode a value larger than (2^16)-1 bytes will result in an error.

fun box array_16(
  b: Writer ref,
  s: U16 val)
: None val

Parameters

Returns


array_32

[Source]

Creates a header for a MessagePack "array_32". This only creates the header. s number of array items should be written via other methods after this is called.

array 32 stores an array whose length is upto (2^32)-1 elements.

Attempting to encode a value larger than (2^32)-1 bytes will result in an error.

fun box array_32(
  b: Writer ref,
  s: U32 val)
: None val

Parameters

Returns


fixmap

[Source]

Creates a header for a MessagePack "fixmap". This only creates the header. s number of map items should be written via other methods after this is called.

fixmap stores a map whose length is upto 15 elements.

Attempting to encode a value larger than 15 will result in an error.

fun box fixmap(
  b: Writer ref,
  s: U8 val)
: None val ?

Parameters

Returns


map_16

[Source]

Creates a header for a MessagePack "map_16". This only creates the header. s number of map items should be written via other methods after this is called.

map 16 stores an array whose length is upto (2^16)-1 elements.

Attempting to encode a value larger than (2^16)-1 bytes will result in an error.

fun box map_16(
  b: Writer ref,
  s: U16 val)
: None val

Parameters

Returns


map_32

[Source]

Creates a header for a MessagePack "map_32". This only creates the header. s number of map items should be written via other methods after this is called.

map 32 stores an array whose length is upto (2^32)-1 elements.

Attempting to encode a value larger than (2^32)-1 bytes will result in an error.

fun box map_32(
  b: Writer ref,
  s: U32 val)
: None val

Parameters

Returns


fixext_1

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

fixext 1 stores an integer and a byte array whose length is 1 byte.

Attempting to encode a ByteSeq that is not 1 element in size will result in an error.

fun box fixext_1(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


fixext_2

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

fixext 2 stores an integer and a byte array whose length is 2 byte.

Attempting to encode a ByteSeq that is not 2 element in size will result in an error.

fun box fixext_2(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


fixext_4

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

fixext 4 stores an integer and a byte array whose length is 4 byte.

Attempting to encode a ByteSeq that is not 4 element in size will result in an error.

fun box fixext_4(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


fixext_8

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

fixext 8 stores an integer and a byte array whose length is 8 byte.

Attempting to encode a ByteSeq that is not 8 element in size will result in an error.

fun box fixext_8(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


fixext_16

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

fixext 16 stores an integer and a byte array whose length is 16 byte.

Attempting to encode a ByteSeq that is not 16 element in size will result in an error.

fun box fixext_16(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


ext_8

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

ext 8 stores an integer and a byte array whose length is upto (2^8)-1 bytes.

Attempting to encode a ByteSeq that is larger than (2^8)-1 bytes in size will result in an error.

fun box ext_8(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


ext_16

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

ext 16 stores an integer and a byte array whose length is upto (2^16)-1 bytes.

Attempting to encode a ByteSeq that is larger than (2^16)-1 bytes in size will result in an error.

fun box ext_16(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


ext_32

[Source]

Allows for the creation of user supplied extensions to the MessagePack format. User should provide not just the value v to be encoded, but a unique type identifier t as well.

Type identifiers 0 to 127 are valid for user supplied types. MessagePack reserves -1 to -128 for future extension to add predefined types.

ext 32 stores an integer and a byte array whose length is upto (2^32)-1 bytes.

Attempting to encode a ByteSeq that is larger than (2^32)-1 bytes in size will result in an error.

fun box ext_32(
  b: Writer ref,
  t: U8 val,
  v: (String val | Array[U8 val] val))
: None val ?

Parameters

Returns


timestamp_32

[Source]

timestamp 32 stores the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC in a 32-bit unsigned integer.

It can represent a timestamp in [1970-01-01 00:00:00 UTC, 2106-02-07 06:28:16 UTC).

Nanoseconds part is 0.

fun box timestamp_32(
  b: Writer ref,
  sec: U32 val)
: None val

Parameters

Returns


timestamp_64

[Source]

timestamp 64 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC in 32-bit unsigned integers.

It can represent a timestamp in [1970-01-01 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC).

nsec must not be larger than 999999999. sec must not be larger than (2^34 - 1).

fun box timestamp_64(
  b: Writer ref,
  sec: U64 val,
  nsec: U32 val)
: None val ?

Parameters

Returns


timestamp_96

[Source]

timestamp 96 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC in 64-bit signed integer and 32-bit unsigned integer.

It can represent a timestamp in [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16.000000000 UTC).

nsec must not be larger than 999999999.

fun box timestamp_96(
  b: Writer ref,
  sec: I64 val,
  nsec: U32 val)
: None val ?

Parameters

Returns


eq

[Source]

fun box eq(
  that: MessagePackEncoder val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: MessagePackEncoder val)
: Bool val

Parameters

Returns