Skip to main content

ReadableBytes

Trait ReadableBytes 

Source
pub trait ReadableBytes: Debug {
    // Required methods
    fn len(&self) -> u64;
    fn read_at(
        &self,
        offset: u64,
        target: &mut [u8],
    ) -> Result<(), ByteAccessError>;

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

Bounded readable bytes exposed by a transport implementation.

Implementations may be segmented. Every operation is nonblocking and allocation-free.

Required Methods§

Source

fn len(&self) -> u64

Stable logical byte length.

Source

fn read_at(&self, offset: u64, target: &mut [u8]) -> Result<(), ByteAccessError>

Fill target from the exact logical range beginning at offset.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether this source contains no bytes.

Source

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

Borrow the complete source when the concrete mapping is contiguous and stable.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ReadableBytes for [u8]

Source§

fn len(&self) -> u64

Source§

fn read_at(&self, offset: u64, target: &mut [u8]) -> Result<(), ByteAccessError>

Source§

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

Implementors§