File Coverage

blib/lib/Argon/Marshal.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 0 4 0.0
total 37 41 90.2


line stmt bran cond sub pod time code
1             package Argon::Marshal;
2             # ABSTRACT: routines for serializing messages
3             $Argon::Marshal::VERSION = '0.17';
4              
5 4     4   164465 use strict;
  4         15  
  4         145  
6 4     4   170 use warnings;
  4         15  
  4         149  
7 4     4   27 use Carp;
  4         16  
  4         279  
8 4     4   26 use Sereal::Decoder qw(sereal_decode_with_object);
  4         10  
  4         280  
9 4     4   28 use Sereal::Encoder qw(SRL_SNAPPY sereal_encode_with_object);
  4         11  
  4         261  
10 4     4   1583 use MIME::Base64 qw(encode_base64 decode_base64);
  4         3030  
  4         282  
11              
12 4     4   253 use parent 'Exporter';
  4         246  
  4         33  
13             our @EXPORT = qw(encode decode encode_msg decode_msg);
14              
15             my $ENC = Sereal::Encoder->new({compress => SRL_SNAPPY});
16             my $DEC = Sereal::Decoder->new();
17              
18 21     21 0 583 sub encode { encode_base64(sereal_encode_with_object($ENC, $_[0]), '') }
19 21     21 0 545 sub decode { sereal_decode_with_object($DEC, decode_base64($_[0])) }
20 20     20 0 43 sub encode_msg { encode(\%{$_[0]}) }
  20         148  
21 20     20 0 118 sub decode_msg { bless decode($_[0]), 'Argon::Message' }
22              
23             1;
24              
25             __END__
26              
27             =pod
28              
29             =encoding UTF-8
30              
31             =head1 NAME
32              
33             Argon::Marshal - routines for serializing messages
34              
35             =head1 VERSION
36              
37             version 0.17
38              
39             =head1 SYNOPSIS
40              
41             use Argon::Marshal;
42              
43             my $data = ['fnord'];
44             my $encoded = encode($data);
45             my $decoded = decode($encoded);
46              
47             my $msg = Argon::Message->new(...);
48             my $encoded = encode_msg($msg);
49             my $decoded = decode_msg($encoded);
50              
51             =head1 DESCRIPTION
52              
53             Provides routines to serialize and deserialize data and L<Argon::Message>s.
54              
55             =head1 AUTHOR
56              
57             Jeff Ober <sysread@fastmail.fm>
58              
59             =head1 COPYRIGHT AND LICENSE
60              
61             This software is copyright (c) 2017 by Jeff Ober.
62              
63             This is free software; you can redistribute it and/or modify it under
64             the same terms as the Perl 5 programming language system itself.
65              
66             =cut