FileContentsWrapper

Struct FileContentsWrapper 

Source
pub struct FileContentsWrapper<T: FileContents> { /* private fields */ }
Expand description

A wrapper for a FileContents object. The wrapper provides some convenience methods and, most importantly, implements ReadRef for &FileContentsWrapper.

Implementations§

Source§

impl<T: FileContents> FileContentsWrapper<T>

Source

pub fn new(file_contents: T) -> Self

Source

pub fn len(&self) -> u64

Source

pub fn is_empty(&self) -> bool

Source

pub fn read_bytes_at( &self, offset: u64, size: u64, ) -> FileAndPathHelperResult<&[u8]>

Source

pub fn read_bytes_at_until( &self, range: Range<u64>, delimiter: u8, ) -> FileAndPathHelperResult<&[u8]>

Source

pub fn read_bytes_into( &self, buffer: &mut Vec<u8>, offset: u64, size: usize, ) -> FileAndPathHelperResult<()>

Append size bytes to buffer, starting to read at offset in the file. If successful, buffer must have had its len increased exactly by size, otherwise the caller may panic.

Source

pub fn read_entire_data(&self) -> FileAndPathHelperResult<&[u8]>

Source

pub fn full_range(&self) -> RangeReadRef<'_, &Self>

Source

pub fn range(&self, start: u64, size: u64) -> RangeReadRef<'_, &Self>

Trait Implementations§

Source§

impl<T: FileContents> Debug for FileContentsWrapper<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'data, T: FileContents> ReadRef<'data> for &'data FileContentsWrapper<T>

Source§

fn len(self) -> Result<u64, ()>

The total size of the block of data.
Source§

fn read_bytes_at(self, offset: u64, size: u64) -> Result<&'data [u8], ()>

Get a reference to a u8 slice at the given offset. Read more
Source§

fn read_bytes_at_until( self, range: Range<u64>, delimiter: u8, ) -> Result<&'data [u8], ()>

Get a reference to a delimited u8 slice which starts at range.start. Read more
Source§

fn read_bytes(self, offset: &mut u64, size: u64) -> Result<&'a [u8], ()>

Get a reference to a u8 slice at the given offset, and update the offset. Read more
Source§

fn read<T>(self, offset: &mut u64) -> Result<&'a T, ()>
where T: Pod,

Get a reference to a Pod type at the given offset, and update the offset. Read more
Source§

fn read_at<T>(self, offset: u64) -> Result<&'a T, ()>
where T: Pod,

Get a reference to a Pod type at the given offset. Read more
Source§

fn read_slice<T>(self, offset: &mut u64, count: usize) -> Result<&'a [T], ()>
where T: Pod,

Get a reference to a slice of a Pod type at the given offset, and update the offset. Read more
Source§

fn read_slice_at<T>(self, offset: u64, count: usize) -> Result<&'a [T], ()>
where T: Pod,

Get a reference to a slice of a Pod type at the given offset. Read more
Source§

impl<'s, F: FileContents> Source<'s> for &'s FileContentsWrapper<F>

Source§

fn view( &mut self, slices: &[SourceSlice], ) -> Result<Box<dyn SourceView<'s> + Send + Sync>, Error>

Provides a contiguous view of the source file composed of the requested position(s). Read more

Auto Trait Implementations§

§

impl<T> Freeze for FileContentsWrapper<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for FileContentsWrapper<T>
where T: RefUnwindSafe,

§

impl<T> Send for FileContentsWrapper<T>

§

impl<T> Sync for FileContentsWrapper<T>

§

impl<T> Unpin for FileContentsWrapper<T>
where T: Unpin,

§

impl<T> UnwindSafe for FileContentsWrapper<T>
where T: UnwindSafe,

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> 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, 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,