Giter Site home page Giter Site logo

data-messagepack-stream's Introduction

Build Status

NAME

Data::MessagePack::Stream - yet another messagepack streaming deserializer

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);
    }
}

DESCRIPTION

Data::MessagePack::Stream is streaming deserializer for MessagePack.

This module is alternate for Data::MessagePack::Unpacker. Unlike original unpacker, this module support internal buffer and it's possible to handle streaming data correctly.

METHODS

new

my $unpacker = Data::MessagePack::Stream->new;

Create new stream unpacker.

feed($data)

$unpacker->feed($data);

Push $data into unpacker's internal buffer.

next

my $bool = $unpacker->next;

If parsable MessagePack packet is fed, return true. You can get that parsed data by data method described below.

data

my $data = $unpacker->data;

Return parsed perl object.

AUTHOR

Daisuke Murase [email protected]

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.

data-messagepack-stream's People

Contributors

typester avatar syohex avatar gugod avatar skaji avatar dolmen avatar

Stargazers

Maxime Soulé avatar  avatar Reini Urban avatar  avatar

Watchers

 avatar Tokuhiro Matsuno avatar  avatar  avatar James Cloos avatar

data-messagepack-stream's Issues

Failed to build Data-MessagePack-Stream on M1 Mac

❯ perl Build.PL
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Data-MessagePack-Stream' version '1.04'

❯ ./Build
Building Data-MessagePack-Stream
checking for a BSD-compatible install... /opt/homebrew/opt/coreutils/libexec/gnubin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/homebrew/opt/coreutils/libexec/gnubin/mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking if C++ API is enabled...
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... Invalid configuration `arm64-apple-darwin20.3.0': machine `arm64-apple' not recognized
configure: error: /bin/sh ac/config.sub arm64-apple-darwin20.3.0 failed
Died at builder/MyBuilder.pm line 54.

Wrong unpacking

A test is worth a thousand words :) I use FreeBSD-8/amd64 with perl-5.12.4 and Linux-2.6.18/arm with perl-5.10.1.

use 5.010;
use Test::More;
use Data::MessagePack::Stream;
use Data::MessagePack;
my $orig = [0,0,200,''];
my $packed = Data::MessagePack->new->pack($orig);
my $unpacker = Data::MessagePack::Stream->new;
$unpacker->feed($packed);
if ($unpacker->next)
{
    is_deeply($unpacker->data, $orig);
}
is_deeply(Data::MessagePack->new->unpack($packed), $orig);
say "Data::MessagePack::Stream::VERSION=$Data::MessagePack::Stream::VERSION";
not ok 1
#   Failed test at - line 9.
#     Structures begin differing at:
#          $got->[3] = 'È ' <- weird characters...
#     $expected->[3] = ''
ok 2
Data::MessagePack::Stream::VERSION=0.06

If I change $orig to [0,0,''], undef is read in $got->[2] instead of ''.

Regards,

Max.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.