mod reader;
mod writer;
pub use reader::{EncoderReader, EncoderReaderParts};
pub use writer::EncoderWriter;
use std::io::{Read, Write};
use super::dictionary::PreparedDictionary;
use super::encoder::Compressor;
use super::error::EncodeError;
use super::session::StreamConfig;
impl Compressor {
pub fn writer<W: Write>(&mut self, sink: W, stream: StreamConfig) -> EncoderWriter<'_, W> {
EncoderWriter::new(self.start(stream), sink)
}
pub fn reader<R: Read>(&mut self, source: R, stream: StreamConfig) -> EncoderReader<'_, R> {
EncoderReader::new(self.start(stream), source)
}
pub fn writer_with_dictionary<'c, W: Write>(
&'c mut self,
dictionary: &'c PreparedDictionary,
sink: W,
stream: StreamConfig,
) -> Result<EncoderWriter<'c, W>, EncodeError> {
Ok(EncoderWriter::new(
self.start_with_dictionary(dictionary, stream)?,
sink,
))
}
pub fn reader_with_dictionary<'c, R: Read>(
&'c mut self,
dictionary: &'c PreparedDictionary,
source: R,
stream: StreamConfig,
) -> Result<EncoderReader<'c, R>, EncodeError> {
Ok(EncoderReader::new(
self.start_with_dictionary(dictionary, stream)?,
source,
))
}
}