File Coverage

blib/lib/IO/Uncompress/Adapter/UnZstd.pm
Criterion Covered Total %
statement 35 42 83.3
branch 4 4 100.0
condition 2 3 66.6
subroutine 9 14 64.2
pod 0 8 0.0
total 50 71 70.4


line stmt bran cond sub pod time code
1             package IO::Uncompress::Adapter::UnZstd;
2              
3 12     12   265867 use strict;
  12         60  
  12         346  
4 12     12   62 use warnings;
  12         24  
  12         337  
5 12     12   91 use bytes;
  12         22  
  12         76  
6              
7 12     12   410 use IO::Compress::Base::Common 2.204 qw(:Status);
  12         216  
  12         1362  
8 12     12   1834 use Compress::Stream::Zstd ;
  12         3124  
  12         924  
9 12     12   5221 use Compress::Stream::Zstd::Decompressor qw(ZSTD_DSTREAM_IN_SIZE);
  12         2684  
  12         4119  
10             our ($VERSION, @ISA);
11             $VERSION = '2.204';
12              
13              
14             sub mkUncompObject
15             {
16              
17 920     920 0 52168 my $decompressor = Compress::Stream::Zstd::Decompressor->new;
18              
19 920         6023 return bless {
20             'Inf' => $decompressor,
21              
22             'CompBytes' => 0,
23             'UnCompBytes' => 0,
24             'Error' => '',
25             'ErrorNo' => 0,
26             'ConsumesInput' => 0,
27             } ;
28             }
29              
30             sub uncompr
31             {
32 2618     2618 0 382196 my $self = shift ;
33 2618         3686 my $from = shift ;
34 2618         3742 my $to = shift ;
35             # my $eof = shift ;
36              
37 2618         4165 my $inf = $self->{Inf};
38              
39 2618         4115 eval { $$to .= $inf->decompress($$from); } ;
  2618         15069  
40              
41 2618 100 66     14340 if ($@ || $inf->isError())
42             {
43 22         93 $self->{Error} = $inf->getErrorName();
44 22         68 $self->{ErrorNo} = $inf->status() ;
45 22         56 return STATUS_ERROR ;
46             }
47              
48 2596         4762 $self->{Error} = "" ;
49 2596         3604 $self->{ErrorNo} = 0;
50              
51 2596 100       6573 return STATUS_ENDSTREAM if $inf->isEndFrame() ;
52              
53 2236         4313 return STATUS_OK ;
54             }
55              
56             sub reset
57             {
58 1     1 0 352 return STATUS_OK ;
59             }
60              
61             #sub count
62             #{
63             # my $self = shift ;
64             # $self->{UnCompBytes};
65             #}
66              
67             sub compressedBytes
68             {
69 0     0 0   my $self = shift ;
70 0           $self->{CompBytes};
71             }
72              
73             sub uncompressedBytes
74             {
75 0     0 0   my $self = shift ;
76 0           $self->{UnCompBytes};
77             }
78              
79             sub crc32
80             {
81 0     0 0   my $self = shift ;
82             #$self->{Inf}->crc32();
83             }
84              
85             sub adler32
86             {
87 0     0 0   my $self = shift ;
88             #$self->{Inf}->adler32();
89             }
90              
91             sub sync
92             {
93 0     0 0   my $self = shift ;
94             }
95              
96             1;
97              
98             __END__