Struct autocompress::io::RayonWriter
source · pub struct RayonWriter<W: Write + Send + 'static, TB: ThreadBuilder = RayonThreadBuilder> { /* private fields */ }
Available on crate feature
rayon
only.Expand description
Off load write operation to another thread.
If you use this writer with compressor, this writer will run compression in another thread. This writer cannot parallelize compression process.
Example
use autocompress::io::RayonWriter;
use autocompress::zstd::ZstdCompressWriter;
let file_writer = File::create("target/rayon-doc-write.zst")?;
let zstd_writer = ZstdCompressWriter::new(file_writer);
let mut rayon_writer = RayonWriter::new(zstd_writer);
rayon_writer.write_all(&b"Hello, world\n"[..])?;
Implementations§
source§impl<W: Write + Send + 'static> RayonWriter<W, RayonThreadBuilder>
impl<W: Write + Send + 'static> RayonWriter<W, RayonThreadBuilder>
pub fn with_capacity(writer: W, capacity: usize) -> Self
pub fn new(writer: W) -> Self
source§impl<W: Write + Send + 'static, TB: ThreadBuilder> RayonWriter<W, TB>
impl<W: Write + Send + 'static, TB: ThreadBuilder> RayonWriter<W, TB>
pub fn with_thread_builder_and_capacity( writer: W, thread_builder: TB, capacity: usize ) -> Self
pub fn into_inner(self) -> W
Trait Implementations§
source§impl<W: Write + Send + 'static, TB: ThreadBuilder> Drop for RayonWriter<W, TB>
impl<W: Write + Send + 'static, TB: ThreadBuilder> Drop for RayonWriter<W, TB>
source§impl<W: Write + Send + 'static, TB: ThreadBuilder> Write for RayonWriter<W, TB>
impl<W: Write + Send + 'static, TB: ThreadBuilder> Write for RayonWriter<W, TB>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush 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, TB> RefUnwindSafe for RayonWriter<W, TB>where
TB: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, TB> Send for RayonWriter<W, TB>where
TB: Send,
impl<W, TB = RayonThreadBuilder> !Sync for RayonWriter<W, TB>
impl<W, TB> Unpin for RayonWriter<W, TB>
impl<W, TB> UnwindSafe for RayonWriter<W, TB>where
TB: UnwindSafe,
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