Struct BytesSource

Source
pub struct BytesSource { /* private fields */ }
Expand description

A U8Source that uses a Bytes object from the wonderful bytes crate to store its underlying data. This source can only use u8s as its item.

Trait Implementations§

Source§

impl Clone for BytesSource

Source§

fn clone(&self) -> BytesSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<BytesSource> for Bytes

Source§

fn from(src: BytesSource) -> Bytes

Converts to this type from the input type.
Source§

impl Source for BytesSource

Source§

type Item = u8

The type of item the Source and its generated Segments will hold.
Source§

fn initial_offset(&self) -> usize

The initial offset of the Source. For more information, see the Offsets section of the Source documentation.
Source§

fn size(&self) -> usize

The amount of data in the reader. If the reader’s size changes (which none of the implementations currently do), then this should return how much data was initially in the reader.
Source§

fn from_vec_with_offset( items: Vec<Self::Item>, initial_offset: usize, ) -> Result<Self>

Creates a new source with the provided initial offset, using the items in theVec for its data.
Source§

fn segment(&self, start: usize, end: usize) -> Result<Segment<'_, u8>>

Creates a segment from the start offset (inclusive) to the end offset (exclusive).
Source§

fn from_vec(items: Vec<Self::Item>) -> Result<Self>

Creates a new source using the data in the Vec for its data.
Source§

fn validate_offset(&self, offset: usize) -> Result<()>

Checks to make sure that the provided offset is valid. If it is, then an Ok(()) will be returned. Otherwise, the appropriate error will be returned.
Source§

fn all(&self) -> Result<Segment<'_, Self::Item>>

Returns a single segment containing all data in the source.
Source§

fn get_n( &self, offset: usize, num_items: usize, ) -> Result<Segment<'_, Self::Item>>

Gets a segment of n items, starting at the given offset.
Source§

fn all_before(&self, offset: usize) -> Result<Segment<'_, Self::Item>>

Gets all items in the source before the provided offset (exclusive).
Source§

fn all_after(&self, offset: usize) -> Result<Segment<'_, Self::Item>>

Gets all items in the source after the provided offset (inclusive).
Source§

fn lower_offset_limit(&self) -> usize

The lowest valid offset that can be requested.
Source§

fn upper_offset_limit(&self) -> usize

The highest valid offset that can be requested.
Source§

impl U8Source for BytesSource

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.
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_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_u8_slice_with_offset( items: &[u8], initial_offset: usize, endidness: Endidness, ) -> Result<Self>

Creates a new source using the the provided slice, Endidness, and offset. Read more
Source§

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

Creates a new source using the the provided slice and Endidness. Read more
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_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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.