pub struct MappedFileSource { /* private fields */ }
Expand description
A U8Source
whose data is owned by a memory mapped file. This source can only use u8
s as
its item.
An important note: The mapped file is locked first via an advisory lock. This is to prevent changes to the file while it is mapped. However, this is just an advisory lock, and other processes may choose to ignore it. So, it’s best not to alter it while it’s mapped.
Implementations§
Trait Implementations§
Source§impl Drop for MappedFileSource
impl Drop for MappedFileSource
Source§impl Source for MappedFileSource
impl Source for MappedFileSource
Source§fn size(&self) -> usize
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 initial_offset(&self) -> usize
fn initial_offset(&self) -> usize
Source§fn from_vec_with_offset(
items: Vec<Self::Item>,
initial_offset: usize,
) -> Result<Self>
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 the
Vec
for its
data.Source§fn segment(&self, start: usize, end: usize) -> Result<Segment<'_, u8>>
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>
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<()>
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>>
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>>
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>>
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>>
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
fn lower_offset_limit(&self) -> usize
The lowest valid offset that can be requested.
Source§fn upper_offset_limit(&self) -> usize
fn upper_offset_limit(&self) -> usize
The highest valid offset that can be requested.
Source§impl U8Source for MappedFileSource
impl U8Source for MappedFileSource
Source§fn 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.Source§fn from_bytes_with_offset(
bytes: Bytes,
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
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 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
.Source§fn from_u8_slice_with_offset(
bytes: &[u8],
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
fn from_u8_slice_with_offset( bytes: &[u8], initial_offset: usize, endidness: Endidness, ) -> Result<Self>
Source§fn change_endidness(&mut self, endidness: Endidness)
fn change_endidness(&mut self, endidness: Endidness)
Source§fn 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
.Source§fn 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.Source§fn 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
.Source§fn 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
.Auto Trait Implementations§
impl Freeze for MappedFileSource
impl RefUnwindSafe for MappedFileSource
impl Send for MappedFileSource
impl Sync for MappedFileSource
impl Unpin for MappedFileSource
impl UnwindSafe for MappedFileSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more