Skip to main content

Source

Trait Source 

Source
pub trait Source: Send + Sync {
    // Required methods
    fn len(&self) -> u64;
    fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<()>;

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

Random access to the bytes of an archive.

Required Methods§

Source

fn len(&self) -> u64

Total length in bytes.

Source

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

Fills buf from offset; fails if the range is out of bounds.

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

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

The whole content when it already sits in memory, so reads can borrow it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Source for Vec<u8>

Source§

fn len(&self) -> u64

Source§

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

Source§

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

Implementors§