Trait U8Source

Source
pub trait U8Source: Source<Item = u8> {
    // Required methods
    fn endidness(&self) -> Endidness;
    fn change_endidness(&mut self, endidness: Endidness);
    fn from_u8_slice_with_offset(
        slice: &[u8],
        initial_offset: usize,
        endidness: Endidness,
    ) -> Result<Self>;
    fn from_file_with_offset<P: AsRef<Path>>(
        path: P,
        initial_offset: usize,
        endidness: Endidness,
    ) -> Result<Self>;
    fn from_file_with_offset_async<'async_trait, P>(
        path: P,
        initial_offset: usize,
        endidness: Endidness,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where P: AsRef<Path> + Sync + Send + 'async_trait,
             Self: 'async_trait;
    fn from_bytes_with_offset(
        bytes: Bytes,
        initial_offset: usize,
        endidness: Endidness,
    ) -> Result<Self>;

    // Provided methods
    fn from_u8_slice(slice: &[u8], endidness: Endidness) -> Result<Self> { ... }
    fn from_u8_vec(items: Vec<u8>, endidness: Endidness) -> Result<Self> { ... }
    fn from_u8_vec_with_offset(
        items: Vec<u8>,
        initial_offset: usize,
        endidness: Endidness,
    ) -> Result<Self> { ... }
    fn from_file<P: AsRef<Path>>(path: P, endidness: Endidness) -> Result<Self> { ... }
    fn from_file_async<'async_trait, P>(
        path: P,
        endidness: Endidness,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where P: AsRef<Path> + Sync + Send + 'async_trait,
             Self: Send + 'async_trait { ... }
    fn from_bytes(bytes: Bytes, endidness: Endidness) -> Result<Self> { ... }
}
Expand description

Segsource is mostly meant to work with binary data (although it by no means has to). Because of this, sources can have some extra functionality when its item type is u8.

Required Methods§

Source

fn endidness(&self) -> Endidness

The endidness of the source.

Source

fn change_endidness(&mut self, endidness: Endidness)

Changes the default endidness. This does not change the endidness for any Segments that have already been created, but only for Segments that are created in the future.

Source

fn from_u8_slice_with_offset( slice: &[u8], initial_offset: usize, endidness: Endidness, ) -> Result<Self>

Creates a new source using the the provided slice, Endidness, and offset.

Note: because sources own their data, this will copy the data from the provided slice.

Source

fn from_file_with_offset<P: AsRef<Path>>( path: P, initial_offset: usize, endidness: Endidness, ) -> Result<Self>

Creates a new source using the the provided file, Endidness, and offset.

Source

fn from_file_with_offset_async<'async_trait, P>( path: P, initial_offset: usize, endidness: Endidness, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where P: AsRef<Path> + Sync + Send + 'async_trait, Self: 'async_trait,

An async version of U8Source::from_file_with_offset.

Source

fn from_bytes_with_offset( bytes: Bytes, initial_offset: usize, endidness: Endidness, ) -> Result<Self>

Creates a new source using the the provided Bytes, Endidness, and offset.

Provided Methods§

Source

fn from_u8_slice(slice: &[u8], endidness: Endidness) -> Result<Self>

Creates a new source using the the provided slice and Endidness.

Note: because sources own their data, this will copy the data from the provided slice.

Source

fn from_u8_vec(items: Vec<u8>, endidness: Endidness) -> Result<Self>

Creates a new source using the the provided vec and Endidness.

Source

fn from_u8_vec_with_offset( items: Vec<u8>, initial_offset: usize, endidness: Endidness, ) -> Result<Self>

Creates a new source using the the provided vec, Endidness, and offset.

Source

fn from_file<P: AsRef<Path>>(path: P, endidness: Endidness) -> Result<Self>

Creates a new source using the the provided file and Endidness.

Source

fn from_file_async<'async_trait, P>( path: P, endidness: Endidness, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where P: AsRef<Path> + Sync + Send + 'async_trait, Self: Send + 'async_trait,

An async version of U8Source::from_file.

Source

fn from_bytes(bytes: Bytes, endidness: Endidness) -> Result<Self>

Creates a new source using the the provided Bytes and Endidness.

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§