MessagePackEncoder¶
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.
Constructors¶
create¶
Returns¶
- MessagePackEncoder val^
Public Functions¶
nil¶
nil format stores nil in 1 byte.
Parameters¶
- b: Writer ref
Returns¶
- None val
bool¶
bool format family stores false or true in 1 byte.
Parameters¶
Returns¶
- None val
positive_fixint¶
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
.
Parameters¶
Returns¶
- None val ?
negative_fixint¶
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
.
Parameters¶
Returns¶
- None val ?
uint_8¶
uint 8 stores a 8-bit unsigned integer.
Parameters¶
Returns¶
- None val
uint_16¶
uint 16 stores a 16-bit big-endian unsigned integer.
Parameters¶
Returns¶
- None val
uint_32¶
uint 32 stores a 32-bit big-endian unsigned integer.
Parameters¶
Returns¶
- None val
uint_64¶
uint 64 stores a 64-bit big-endian unsigned integer.
Parameters¶
Returns¶
- None val
int_8¶
int 8 stores a 8-bit signed integer.
Parameters¶
Returns¶
- None val
int_16¶
int 16 stores a 16-bit big-endian signed integer.
Parameters¶
Returns¶
- None val
int_32¶
int 32 stores a 32-bit big-endian signed integer.
Parameters¶
Returns¶
- None val
int_64¶
int 64 stores a 64-bit big-endian signed integer.
Parameters¶
Returns¶
- None val
float_32¶
float 32 stores a floating point number in IEEE 754 single precision floating point number format.
Parameters¶
Returns¶
- None val
float_64¶
float 64 stores a floating point number in IEEE 754 double precision floating point number format.
Parameters¶
Returns¶
- None val
fixstr¶
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
.
Parameters¶
Returns¶
- None val ?
str_8¶
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
.
Parameters¶
Returns¶
- None val ?
str_16¶
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
.
Parameters¶
Returns¶
- None val ?
str_32¶
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
.
Parameters¶
Returns¶
- None val ?
bin_8¶
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
.
Parameters¶
Returns¶
- None val ?
bin_16¶
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
.
Parameters¶
Returns¶
- None val ?
bin_32¶
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
.
Parameters¶
Returns¶
- None val ?
fixarray¶
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
.
Parameters¶
Returns¶
- None val ?
array_16¶
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
.
Parameters¶
Returns¶
- None val
array_32¶
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
.
Parameters¶
Returns¶
- None val
fixmap¶
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
.
Parameters¶
Returns¶
- None val ?
map_16¶
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
.
Parameters¶
Returns¶
- None val
map_32¶
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
.
Parameters¶
Returns¶
- None val
fixext_1¶
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
.
Parameters¶
Returns¶
- None val ?
fixext_2¶
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
.
Parameters¶
Returns¶
- None val ?
fixext_4¶
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
.
Parameters¶
Returns¶
- None val ?
fixext_8¶
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
.
Parameters¶
Returns¶
- None val ?
fixext_16¶
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
.
Parameters¶
Returns¶
- None val ?
ext_8¶
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
.
Parameters¶
Returns¶
- None val ?
ext_16¶
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
.
Parameters¶
Returns¶
- None val ?
ext_32¶
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
.
Parameters¶
Returns¶
- None val ?
timestamp_32¶
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.
Parameters¶
Returns¶
- None val
timestamp_64¶
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).
Parameters¶
Returns¶
- None val ?
timestamp_96¶
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.
Parameters¶
Returns¶
- None val ?
eq¶
Parameters¶
- that: MessagePackEncoder val
Returns¶
- Bool val
ne¶
Parameters¶
- that: MessagePackEncoder val
Returns¶
- Bool val