Struct object::read::ReadCache[][src]

pub struct ReadCache<R: Read + Seek> { /* fields omitted */ }
Expand description

An implementation of ReadRef for data in a stream that implements Read + Seek.

Contains a cache of read-only blocks of data, allowing references to them to be returned. Entries in the cache are never removed. Entries are keyed on the offset and size of the read. Currently overlapping reads are considered separate reads.

Implementations

impl<R: Read + Seek> ReadCache<R>[src]

pub fn new(read: R) -> Self[src]

Create an empty ReadCache for the given stream.

pub fn range(&self, offset: u64, size: u64) -> ReadCacheRange<'_, R>[src]

Return an implementation of ReadRef that restricts reads to the given range of the stream.

pub fn clear(&mut self)[src]

Free buffers used by the cache.

pub fn into_inner(self) -> R[src]

Unwrap this ReadCache<R>, returning the underlying reader.

Trait Implementations

impl<R: Debug + Read + Seek> Debug for ReadCache<R>[src]

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

Formats the value using the given formatter. Read more

impl<'a, R: Read + Seek> ReadRef<'a> for &'a ReadCache<R>[src]

fn len(self) -> Result<u64, ()>[src]

The total size of the block of data.

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

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

fn read_bytes_at_until(self, offset: u64, delimiter: u8) -> Result<&'a [u8], ()>[src]

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

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

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

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

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

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

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

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

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

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

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

Auto Trait Implementations

impl<R> !RefUnwindSafe for ReadCache<R>

impl<R> Send for ReadCache<R> where
    R: Send

impl<R> !Sync for ReadCache<R>

impl<R> Unpin for ReadCache<R> where
    R: Unpin

impl<R> UnwindSafe for ReadCache<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.