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§
Sourcefn change_endidness(&mut self, endidness: Endidness)
fn change_endidness(&mut self, endidness: Endidness)
Sourcefn from_u8_slice_with_offset(
slice: &[u8],
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
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.
Sourcefn from_file_with_offset<P: AsRef<Path>>(
path: P,
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
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.
Sourcefn 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>>
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>>
An async version of U8Source::from_file_with_offset
.
Provided Methods§
Sourcefn from_u8_slice(slice: &[u8], endidness: Endidness) -> Result<Self>
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.
Sourcefn from_u8_vec(items: Vec<u8>, endidness: Endidness) -> Result<Self>
fn from_u8_vec(items: Vec<u8>, endidness: Endidness) -> Result<Self>
Creates a new source using the the provided vec and Endidness
.
Sourcefn from_u8_vec_with_offset(
items: Vec<u8>,
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
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.
Sourcefn from_file<P: AsRef<Path>>(path: P, endidness: Endidness) -> Result<Self>
fn from_file<P: AsRef<Path>>(path: P, endidness: Endidness) -> Result<Self>
Creates a new source using the the provided file and Endidness
.
Sourcefn from_file_async<'async_trait, P>(
path: P,
endidness: Endidness,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
fn from_file_async<'async_trait, P>( path: P, endidness: Endidness, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
An async version of U8Source::from_file
.
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.