NAME
Data::MessagePack::Unpacker - messagepack streaming deserializer
SYNOPSIS
use Data::Dumper;
my $up = Data::MessagePack::Unpacker->new;
open my $fh, $data or die $!;
my $offset = 0;
while( read($fh, my $buf, 1024) ) {
$offset = $up->execute($buf, $offset);
if($up->is_finished) {
print Dumper($up->data);
}
}
DESCRIPTION
This is a streaming deserializer for messagepack.
METHODS
- my $up = Data::MessagePack::Unpacker->new()
-
creates a new instance of the stream deserializer.
- $up->utf8([$bool])
-
sets utf8 mode. true if $bool is omitted. returns $up itself.
If utf8 mode is enabled, strings will be decoded as UTF-8.
The utf8 mode is disabled by default.
- my $ret = $up->get_utf8()
-
returns the utf8 mode flag of $up.
- $offset = $up->execute($data, $offset);
- $offset = $up->execute_limit($data, $offset, $limit)
-
parses unpacked $data from $offset to $limit. returns a new offset of $data, which is for the next <execute()>.
If $data is insufficient, $offset does not change, saving $data in internal buffers.
- my $bool = $up->is_finished();
-
is this deserializer finished?
- my $data = $up->data();
-
returns the deserialized object.
- $up->reset();
-
resets the stream deserializer, without memory zone.
AUTHORS
Tokuhiro Matsuno