NAME
DR::Tnt::Msgpack - msgpack encoder/decoder.
SYNOPSIS
use DR::Tnt::Msgpack;
use DR::Tnt::Msgpack::Types ':all'; # mp_*
my $blob = msgpack { a => 'b', c => 123, d => [ 3, 4, 5 ] };
my $object = msgunpack $blob;
my $object = msgunpack_utf8 $blob;
my ($object, $len) = msgunpack_safely $blob;
my ($object, $len) = msgunpack_safely_utf8 $blob;
if (defined $len) {
substr $blob, 0, $len, '';
...
}
if (my $len = msgunpack_check $blob) {
# $blob contains msgpack with len=$len
}
METHODS
msgpack
my $blob = msgpack $scalar;
my $blob = msgpack \%hash;
my $blob = msgpack \@array;
Pack any perl object to msgpack. Blessed objects have to have TO_MSGPACK
methods.
msgunpack
Unpack msgpack'ed string to perl object. Throws exception if buffer is invalid. Booleans are extracted to DR::Tnt::Msgpack::Types::Bool, see also DR::Tnt::Msgpack::Types.
msgunpack_utf8
The same as "msgunpack". Decode utf8 for each string.
msgunpack_safely, msgunpack_safely_utf8
Unpack msgpack'ed string to perl object. Don't throw exception if buffer is invalid.
Return unpacked object and length of unpacked object. If length is undef
, buffer is invalid.