Skip to main content

chapter_tgz/
io.rs

1//! std::io impls
2
3use crate::TgzWriter;
4use crate::refmut::RefMut;
5use flate2::read::{DeflateDecoder, GzDecoder};
6use std::io::{ErrorKind, Take, Write};
7use std::ops::Range;
8
9/// std::io::Write type used by [TgzWriter]
10pub struct ChapterWriter<'a, W: Write> {
11    pub(crate) tgz: &'a mut TgzWriter<W>,
12    pub(crate) index: u32,
13    pub(crate) deferred_termination_sections: bool,
14}
15
16/// std::io::Read type used by [TgzReader][crate::TgzReader]
17pub struct ChapterReader<'a, R> {
18    pub(crate) imp: ChapterReaderImpl<'a, R>,
19}
20
21pub(crate) enum ChapterReaderImpl<'a, R> {
22    SeekTo(Range<u64>, RefMut<'a, R>),
23    Smart(DeflateDecoder<Take<RefMut<'a, R>>>),
24    Dumb(GzDecoder<RefMut<'a, R>>),
25    Failed(ErrorKind),
26}