1 package IO
::Uncompress
::Brotli
;
6 use parent qw
/Exporter/;
8 our @EXPORT = qw
/unbro/;
9 our @EXPORT_OK = @EXPORT;
11 our $VERSION = '0.001001';
14 XSLoader
::load
('IO::Compress::Brotli', $VERSION);
18 my $state = BrotliCreateState
();
24 BrotliDestroyState
($$self)
28 my ($self, $data) = @_;
29 BrotliDecompressStream
($$self, $data)
32 # Untested, probably not working
34 my ($self, $dict) = @_;
35 BrotliSetCustomDictionary
($$self, $dict)
45 IO::Uncompress::Brotli - Read Brotli buffers/streams
49 use IO::Uncompress::Brotli;
52 my $decoded = unbro $encoded;
55 my $bro = IO::Uncompress::Brotli->create;
57 my $block = get_input_block();
58 my $decoded_block = $bro->decompress($block);
59 handle_output_block($decoded_block);
64 IO::Uncompress::Brotli is a module that decompresses Brotli buffers
65 and streams. Despite its name, it is not a subclass of
66 L<IO::Uncompress::Base> and does not implement its interface. This
67 will be rectified in a future release.
69 =head2 One-shot interface
71 If you have the whole buffer in a Perl scalar use the B<unbro>
76 =item B<unbro>(I<$input>)
78 Takes a whole compressed buffer as input and returns the decompressed
79 data. This function relies on the BrotliDecompressedSize function. In
80 other words, it only works if the buffer has a single meta block or
81 two meta-blocks where the first is uncompressed and the second is
88 =head2 Streaming interface
90 If you want to process the data in blocks use the object oriented
91 interface. The available methods are:
95 =item IO::Uncompress::Brotli->B<create>
97 Returns a IO::Uncompress::Brotli instance. Please note that a single
98 instance cannot be used to decompress multiple streams.
100 =item $bro->B<decompress>(I<$block>)
102 Takes the a block of compressed data and returns a block of
103 uncompressed data. Dies on error.
109 Brotli Compressed Data Format Internet-Draft:
110 L<https://www.ietf.org/id/draft-alakuijala-brotli-08.txt>
112 Brotli source code: L<https://github.com/google/brotli/>
116 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
118 =head1 COPYRIGHT AND LICENSE
120 Copyright (C) 2015 by Marius Gavrilescu
122 This library is free software; you can redistribute it and/or modify
123 it under the same terms as Perl itself, either Perl version 5.20.2 or,
124 at your option, any later version of Perl 5 you may have available.