pub struct LockedReadHandle<'handle, 'invoker, 'buffer, B: Buffer> { /* private fields */ }
Expand description

A readable file handle on which methods can be invoked.

This type combines a readable file handle, an Invoker that can be used to make method calls, and a scratch buffer used to perform CBOR encoding and decoding. A value of this type can be created by calling ReadHandle::lock, and it can be dropped to return the borrow of the invoker and buffer to the caller so they can be reused for other purposes.

The 'handle lifetime is the lifetime of the original file handle. The 'invoker lifetime is the lifetime of the invoker. The 'buffer lifetime is the lifetime of the buffer. The B type is the type of scratch buffer to use.

Implementations§

source§

impl<'handle, 'invoker, 'buffer, B: Buffer> LockedReadHandle<'handle, 'invoker, 'buffer, B>

source

pub async fn seek(&mut self, basis: Seek, offset: i64) -> Result<u64, Error>

Seeks to a position in the file and returns the resulting absolute byte position.

§Errors
source

pub async fn read(self, length: usize) -> Result<Option<&'buffer [u8]>, Error>

Reads bytes from the file.

None is returned if no bytes were read because the handle’s initial position was at or beyond EOF.

The returned byte slice points into, and therefore retains ownership of, the scratch buffer. Consequently, the LockedReadHandle is consumed and cannot be reused.

§Errors

Auto Trait Implementations§

§

impl<'handle, 'invoker, 'buffer, B> Freeze for LockedReadHandle<'handle, 'invoker, 'buffer, B>
where B: Write + AsMut<[u8]>,

§

impl<'handle, 'invoker, 'buffer, B> RefUnwindSafe for LockedReadHandle<'handle, 'invoker, 'buffer, B>
where B: Write + AsMut<[u8]> + RefUnwindSafe,

§

impl<'handle, 'invoker, 'buffer, B> Send for LockedReadHandle<'handle, 'invoker, 'buffer, B>
where B: Write + AsMut<[u8]> + Send,

§

impl<'handle, 'invoker, 'buffer, B> Sync for LockedReadHandle<'handle, 'invoker, 'buffer, B>
where B: Write + AsMut<[u8]> + Sync,

§

impl<'handle, 'invoker, 'buffer, B> Unpin for LockedReadHandle<'handle, 'invoker, 'buffer, B>
where B: Write + AsMut<[u8]>,

§

impl<'handle, 'invoker, 'buffer, B> !UnwindSafe for LockedReadHandle<'handle, 'invoker, 'buffer, B>

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>,

§

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>,

§

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.