/
Stream.pm
82 lines (48 loc) · 1.57 KB
/
Stream.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package Data::MessagePack::Stream;
use strict;
use warnings;
use XSLoader;
our $VERSION = '0.05';
XSLoader::load __PACKAGE__, $VERSION;
1;
__END__
=for stopwords
messagepack deserializer parsable unpacker unpacker's
=head1 NAME
Data::MessagePack::Stream - yet another messagepack streaming deserializer
=head1 SYNOPSIS
use Data::Dumper;
my $unpacker = Data::MessagePack::Stream->new;
while (read($fh, my $buf, 1024)) {
$unpacker->feed($buf);
while ($unpacker->next) {
print Dumper($unpacker->data);
}
}
=head1 DESCRIPTION
Data::MessagePack::Stream is streaming deserializer for MessagePack.
This module is alternate for L<Data::MessagePack::Unpacker>.
Unlike original unpacker, this module support internal buffer and it's possible to handle streaming data correctly.
=head1 METHODS
=head2 new
my $unpacker = Data::MessagePack::Stream->new;
Create new stream unpacker.
=head2 feed($data)
$unpacker->feed($data);
Push C<$data> into unpacker's internal buffer.
=head2 next
my $bool = $unpacker->next;
If parsable MessagePack packet is fed, return true.
You can get that parsed data by C<data> method described below.
=head2 data
my $data = $unpacker->data;
Return parsed perl object.
=head1 AUTHOR
Daisuke Murase <typester@cpan.org>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2012 by KAYAC Inc.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut