pub struct DivansBrotliHybridCompressorWriter<W: Write>(/* private fields */);Implementations§
Source§impl<W: Write> DivansBrotliHybridCompressorWriter<W>
impl<W: Write> DivansBrotliHybridCompressorWriter<W>
Sourcepub fn new(writer: W, opts: DivansCompressorOptions, buffer_size: usize) -> Self
pub fn new(writer: W, opts: DivansCompressorOptions, buffer_size: usize) -> Self
Examples found in repository?
examples/compress.rs (lines 13-34)
7fn main() {
8 let example_opts = divans::DivansCompressorOptions::default();
9 use std::io;
10 let stdout = &mut io::stdout();
11 {
12 use std::io::{Read, Write};
13 let mut writer = divans::DivansBrotliHybridCompressorWriter::new(
14 stdout,
15 divans::DivansCompressorOptions{
16 brotli_literal_byte_score:example_opts.brotli_literal_byte_score,
17 force_literal_context_mode:example_opts.force_literal_context_mode,
18 literal_adaptation:example_opts.literal_adaptation, // should we override how fast the cdfs converge for literals?
19 window_size:example_opts.window_size, // log 2 of the window size
20 lgblock:example_opts.lgblock, // should we override how often metablocks are created in brotli
21 quality:example_opts.quality, // the quality of brotli commands
22 q9_5:example_opts.q9_5,
23 dynamic_context_mixing:example_opts.dynamic_context_mixing, // if we want to mix together the stride prediction and the context map
24 prior_depth:example_opts.prior_depth,
25 use_brotli:example_opts.use_brotli, // ignored
26 use_context_map:example_opts.use_context_map, // whether we should use the brotli context map in addition to the last 8 bits of each byte as a prior
27 force_stride_value: example_opts.force_stride_value, // if we should use brotli to decide on the stride
28 speed_detection_quality: example_opts.speed_detection_quality,
29 stride_detection_quality: example_opts.stride_detection_quality,
30 prior_bitmask_detection: example_opts.prior_bitmask_detection,
31 divans_ir_optimizer:example_opts.divans_ir_optimizer,
32 },
33 4096, // internal buffer size
34 );
35 let mut buf = [0u8; 4096];
36 loop {
37 match io::stdin().read(&mut buf[..]) {
38 Err(e) => {
39 if let io::ErrorKind::Interrupted = e.kind() {
40 continue;
41 }
42 panic!(e);
43 }
44 Ok(size) => {
45 if size == 0 {
46 match writer.flush() {
47 Err(e) => {
48 if let io::ErrorKind::Interrupted = e.kind() {
49 continue;
50 }
51 panic!(e)
52 }
53 Ok(_) => break,
54 }
55 }
56 match writer.write_all(&buf[..size]) {
57 Err(e) => panic!(e),
58 Ok(_) => {},
59 }
60 }
61 }
62 }
63 }
64}Trait Implementations§
Source§impl<W: Write> Write for DivansBrotliHybridCompressorWriter<W>
impl<W: Write> Write for DivansBrotliHybridCompressorWriter<W>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> Freeze for DivansBrotliHybridCompressorWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for DivansBrotliHybridCompressorWriter<W>where
W: RefUnwindSafe,
impl<W> Send for DivansBrotliHybridCompressorWriter<W>where
W: Send,
impl<W> Sync for DivansBrotliHybridCompressorWriter<W>where
W: Sync,
impl<W> Unpin for DivansBrotliHybridCompressorWriter<W>where
W: Unpin,
impl<W> UnwindSafe for DivansBrotliHybridCompressorWriter<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more