Skip to main content

ByteSink

Trait ByteSink 

Source
pub trait ByteSink: Debug {
    // Required methods
    fn len(&self) -> u64;
    fn write_at(
        &mut self,
        offset: u64,
        source: &[u8],
    ) -> Result<(), BackendError>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn as_contiguous_mut(&mut self) -> Option<&mut [u8]> { ... }
}
Expand description

A bounded byte destination that may be physically segmented.

Providers can write buffer contents directly into validated response regions. The optional contiguous view avoids callback overhead when the destination is already one slice. Every range fully contained in 0..len() must be writable for the duration of the backend call.

Required Methods§

Source

fn len(&self) -> u64

Stable logical length of this destination.

Source

fn write_at(&mut self, offset: u64, source: &[u8]) -> Result<(), BackendError>

Write source to the exact logical range beginning at offset.

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

fn as_contiguous_mut(&mut self) -> Option<&mut [u8]>

Mutably borrow the complete logical destination when it is one contiguous region.

A returned slice has length Self::len and represents the same bytes as write_at.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ByteSink for [u8]

Source§

fn len(&self) -> u64

Source§

fn write_at(&mut self, offset: u64, source: &[u8]) -> Result<(), BackendError>

Source§

fn as_contiguous_mut(&mut self) -> Option<&mut [u8]>

Source§

impl<const N: usize> ByteSink for [u8; N]

Source§

fn len(&self) -> u64

Source§

fn write_at(&mut self, offset: u64, source: &[u8]) -> Result<(), BackendError>

Source§

fn as_contiguous_mut(&mut self) -> Option<&mut [u8]>

Implementors§