Trait StreamingWriter

Source
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§

Source

type Error

The kind of errors that the implementation emits during encoding

Required Methods§

Source

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.

Source

fn share_bytes_mut( &mut self, len: usize, ) -> Result<&mut [MaybeUninit<u8>], Self::Error>

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.

Source

fn flush() -> Result<(), Self::Error>

Ensure that all bytes are fully written in a maximally durable fashion.

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.

Implementors§