| 1 | package Net::IMP::Remote::Sereal; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Net::IMP::Remote::Protocol; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Net::IMP qw(:DEFAULT :log); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Net::IMP::Debug; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Net::IMP::Remote::DualvarMapping; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Sereal::Encoder 0.36; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Sereal::Decoder 0.36; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | my $wire_version = 0x00000001; | |||||||||
| 13 | |||||||||||
| 14 | sub new { | ||||||||||
| 15 | 1 | ▶ | bless { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | encoder => Sereal::Encoder->new, | ||||||||||
| 17 | decoder => Sereal::Decoder->new({ incremental => 1 }), | ||||||||||
| 18 | }, shift; | ||||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | sub buf2rpc { | ||||||||||
| 22 | 35 | ▶ | my ($self,$rdata) = @_; | ||||||||
|
Subroutine
buf2rpc: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||
| 23 | 35 | decode: | |||||||||
| 24 | my $out = undef; | ||||||||||
| 25 | 35 | ▶ | eval { $self->{decoder}->decode( $$rdata, $out ) } or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 12 | ▶ | return if ! $out; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 12 | ▶ | if ( $out->[0] == IMPRPC_SET_VERSION ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 1 | ▶ | die "wrong version $out->[1], can do $wire_version only" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | if $out->[1] != $wire_version; | ||||||||||
| 30 | 1 | ▶ | return if $$rdata eq ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | goto decode; | |||||||||
| 32 | } | ||||||||||
| 33 | 11 | return rpc_i2d($out); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub rpc2buf { | ||||||||||
| 37 | 12 | ▶ | my ($self,$rpc) = @_; | ||||||||
|
Subroutine
rpc2buf: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 38 | 12 | $self->{encoder}->encode(rpc_d2i($rpc)) | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub init { | ||||||||||
| 42 | 1 | ▶ | my ($self,$side) = @_; | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 43 | 1 | ▶ | return if $side == 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 1 | $self->rpc2buf([IMPRPC_SET_VERSION,$wire_version]) | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 2 | 1; | |||||||||