File Coverage

blib/lib/Compress/Zstd/Compressor.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Compress::Zstd::Compressor;
2 1     1   519 use 5.008001;
  1         4  
3 1     1   5 use strict;
  1         2  
  1         19  
4 1     1   4 use warnings;
  1         2  
  1         58  
5 1     1   7 use Exporter 'import';
  1         2  
  1         27  
6              
7 1     1   5 use Compress::Zstd ();
  1         2  
  1         53  
8              
9             our @EXPORT = qw(
10             ZSTD_CSTREAM_IN_SIZE
11             );
12              
13             1;
14             __END__
15              
16             =encoding utf-8
17              
18             =head1 NAME
19              
20             Compress::Zstd::Compressor - Zstd streaming compression
21              
22             =head1 SYNOPSIS
23              
24             use Compress::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE);
25              
26             my $compressor = Compress::Zstd::Compressor->new($level);
27             while (read($fh, my $buffer, ZSTD_CSTREAM_IN_SIZE)) {
28             print $compressor->compress($buffer);
29             }
30             print $compressor->end;
31              
32             =head1 DESCRIPTION
33              
34             The Compress::Zstd::Compressor module provides a streaming interface to the Zstd compressor.
35              
36             =head1 METHODS
37              
38             =head2 Compress::Zstd::Compressor->new([$level]) :Compress::Zstd::Compressor
39              
40             Create an instance of Compress::Zstd::Compressor.
41              
42             =head2 $compressor->init([$level]) :Undef
43              
44             (re)init the compressor.
45              
46             =head2 $compressor->compress($input) :Str
47              
48             Consume input stream.
49              
50             =head2 $compressor->flush() :Str
51              
52             Flush whatever data remains within internal buffer.
53              
54             =head2 $compressor->end() :Str
55              
56             Instructs to finish a frame.
57              
58             =head1 CONSTANTS
59              
60             =head2 ZSTD_CSTREAM_IN_SIZE
61              
62             Recommended size for input buffer.
63              
64             =head1 SEE ALSO
65              
66             L<http://www.zstd.net/>
67              
68             =head1 LICENSE
69              
70             Copyright (c) 2016, Jiro Nishiguchi
71             All rights reserved.
72              
73             Redistribution and use in source and binary forms, with or without modification,
74             are permitted provided that the following conditions are met:
75              
76             1. Redistributions of source code must retain the above copyright notice, this
77             list of conditions and the following disclaimer.
78              
79             2. Redistributions in binary form must reproduce the above copyright notice,
80             this list of conditions and the following disclaimer in the documentation
81             and/or other materials provided with the distribution.
82              
83             THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
84             ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86             DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
87             ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88             (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89             LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
90             ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91             (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
92             SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93              
94             =head1 AUTHOR
95              
96             Jiro Nishiguchi E<lt>jiro@cpan.orgE<gt>
97              
98             Zstandard by Facebook, Inc.
99              
100             =cut