pub struct StreamWriter<'a, F: Write + Seek> { /* private fields */ }Expand description
Allows writing data to a stream.
This object does not implement Seek and there is no variant of this object that allows
seeking or writing to arbitrary offsets. Stream data must be written sequentially.
After a StreamWriter is closed (dropped), it is not possible to create a new StreamWriter
for the same stream.
§Write calls are never split across chunks
The Write implementation of this type makes a guarantee: For a given call to
StreamWriter::write, if the current stream is using chunked compression, then the data will
be written to a single compressed chunk. This is an implementation guarantee; it is not required
by the MSFZ specification.
This allows readers to rely on complete records being stored within a single chunk. For example,
when copying the TPI, an encoder could issue a sequence of write() calls whose boundaries
align with the boundaries of the records within the TPI. This would allow the reader to read
records directly from the chunk decompressed buffer, without needing to allocate a separate
buffer or copy the records. (We do not currently implement that behavior; this is describing a
hypothetical.)
Implementations§
Source§impl<'a, F: Write + Seek> StreamWriter<'a, F>
impl<'a, F: Write + Seek> StreamWriter<'a, F>
Sourcepub fn end_chunk(&mut self) -> Result<()>
pub fn end_chunk(&mut self) -> Result<()>
Ends the current chunk, if any.
This function is a performance hint for compression. It is not necessary to call this function.
Sourcepub fn bytes_available_in_chunk_buffer(&self) -> usize
pub fn bytes_available_in_chunk_buffer(&self) -> usize
The number of bytes that can be written to the current chunk buffer, without exceeding the configured maximum.
Sourcepub fn set_compression_enabled(&mut self, value: bool)
pub fn set_compression_enabled(&mut self, value: bool)
Specifies whether to use chunked compression or not. The default value for this setting is
true (chunked compression is enabled).
This does not have any immediate effect. It controls the behavior of the write()
implementation for this stream.
If this is called with false, then write() calls that follow this will cause stream
data to be written to disk without compression.
Sourcepub fn set_alignment(&mut self, value: Pow2)
pub fn set_alignment(&mut self, value: Pow2)
Specifies the on-disk alignment requirement for the start of the stream data.
This only applies to uncompressed streams. Compressed stream data is always stored within compressed chunks, so the alignment is meaningless.
Trait Implementations§
Source§impl<'a, F: Write + Seek> Write for StreamWriter<'a, F>
impl<'a, F: Write + Seek> Write for StreamWriter<'a, F>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)