Skip to content

Commit 06b8e3f

Browse files
authored
Merge pull request #94 from veldsla/multigzdocs
Extend MultiGzDecoder docs
2 parents 39812e6 + 937b9bf commit 06b8e3f

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

src/gz.rs

+24-10
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,23 @@ pub struct DecoderReader<R: Read> {
7171

7272
/// A gzip streaming decoder that decodes all members of a multistream
7373
///
74-
/// This structure exposes a `Read` interface that will consume compressed
75-
/// data from the underlying reader and emit uncompressed data.
74+
/// A gzip member consists of a header, compressed data and a trailer. The [gzip
75+
/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple
76+
/// gzip members to be joined in a single stream. `MultiDecoderReader` will
77+
/// decode all consecutive members while `DecoderReader` will only decompress the
78+
/// first gzip member. The multistream format is commonly used in bioinformatics,
79+
/// for example when using the BGZF compressed data.
80+
///
81+
/// This structure exposes a `Read` interface that will consume all gzip members
82+
/// from the underlying reader and emit uncompressed data.
7683
pub struct MultiDecoderReader<R: Read> {
7784
inner: MultiDecoderReaderBuf<BufReader<R>>,
7885
}
7986

8087
/// A gzip streaming decoder
8188
///
82-
/// This structure exposes a `Read` interface that will consume all
83-
/// compressed gzip members from the underlying reader and emit uncompressed data.
89+
/// This structure exposes a `Read` interface that will consume compressed
90+
/// data from the underlying reader and emit uncompressed data.
8491
pub struct DecoderReaderBuf<R: BufRead> {
8592
inner: CrcReader<deflate::DecoderReaderBuf<R>>,
8693
header: Header,
@@ -89,8 +96,15 @@ pub struct DecoderReaderBuf<R: BufRead> {
8996

9097
/// A gzip streaming decoder that decodes all members of a multistream
9198
///
92-
/// This structure exposes a `Read` interface that will consume all
93-
/// compressed gzip members from the underlying reader and emit uncompressed data.
99+
/// A gzip member consists of a header, compressed data and a trailer. The [gzip
100+
/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple
101+
/// gzip members to be joined in a single stream. `MultiDecoderReaderBuf` will
102+
/// decode all consecutive members while `DecoderReaderBuf` will only decompress
103+
/// the first gzip member. The multistream format is commonly used in
104+
/// bioinformatics, for example when using the BGZF compressed data.
105+
///
106+
/// This structure exposes a `Read` interface that will consume all gzip members
107+
/// from the underlying reader and emit uncompressed data.
94108
pub struct MultiDecoderReaderBuf<R: BufRead> {
95109
inner: CrcReader<deflate::DecoderReaderBuf<R>>,
96110
header: Header,
@@ -503,8 +517,8 @@ impl<R: Read + Write> Write for DecoderReader<R> {
503517

504518
impl<R: Read> MultiDecoderReader<R> {
505519
/// Creates a new decoder from the given reader, immediately parsing the
506-
/// gzip header. If the gzip stream contains multiple members all will be
507-
/// decoded.
520+
/// (first) gzip header. If the gzip stream contains multiple members all will
521+
/// be decoded.
508522
///
509523
/// If an error is encountered when parsing the gzip header, an error is
510524
/// returned.
@@ -652,8 +666,8 @@ impl<R: BufRead + Write> Write for DecoderReaderBuf<R> {
652666

653667
impl<R: BufRead> MultiDecoderReaderBuf<R> {
654668
/// Creates a new decoder from the given reader, immediately parsing the
655-
/// gzip header. If the gzip stream contains multiple members all will be
656-
/// decoded.
669+
/// (first) gzip header. If the gzip stream contains multiple members all will
670+
/// be decoded.
657671
///
658672
/// If an error is encountered when parsing the gzip header, an error is
659673
/// returned.

0 commit comments

Comments
 (0)