pub trait StreamingWriter {
type Error;
// Required methods
fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error>;
fn share_bytes_mut(
&mut self,
len: usize,
) -> Result<&mut [MaybeUninit<u8>], Self::Error>;
fn flush() -> Result<(), Self::Error>;
}
Expand description
Writer backend trait
Required Associated Types§
Required Methods§
Sourcefn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
Write all of the bytes from the provided buffer into the underlying encoding stream.
Ought to produce an error if not all of the bytes could be written.
N.B. for possible enhancement: We could return size written here rather than leaving that tracking and manner of exposure to the implementing type.
Expose an aliased view of a subset of the underlying data as mutable bytes.
The implementer must ensure that the view of bytes returned does not overlap with the region of bytes that the StreamingWriter allows itself to mutate at any further point.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.