[go: up one dir, main page]

Struct object::read::ReadCache

source ·
pub struct ReadCache<R: Read + Seek> { /* private fields */ }
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§

source§

impl<R: Read + Seek> ReadCache<R>

source

pub fn new(read: R) -> Self

Create an empty ReadCache for the given stream.

source

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

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

source

pub fn clear(&mut self)

Free buffers used by the cache.

source

pub fn into_inner(self) -> R

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

Trait Implementations§

source§

impl<R: Debug + Read + Seek> Debug for ReadCache<R>

source§

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

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

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

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<&'a [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<&'a [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: Pod>(self, offset: &mut u64) -> Result<&'a T, ()>

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

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

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

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

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: Pod>(self, offset: u64, count: usize) -> Result<&'a [T], ()>

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.