Struct oc_wasm_opencomputers::filesystem::LockedReadHandle
source · [−]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
sourceimpl<'handle, 'invoker, 'buffer, B: Buffer> LockedReadHandle<'handle, 'invoker, 'buffer, B>
impl<'handle, 'invoker, 'buffer, B: Buffer> LockedReadHandle<'handle, 'invoker, 'buffer, B>
sourcepub async fn seek(&mut self, basis: Seek, offset: i64) -> Result<u64, Error>
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
sourcepub async fn read(self, length: usize) -> Result<Option<&'buffer [u8]>, Error>
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> RefUnwindSafe for LockedReadHandle<'handle, 'invoker, 'buffer, B> where
B: RefUnwindSafe,
impl<'handle, 'invoker, 'buffer, B> Send for LockedReadHandle<'handle, 'invoker, 'buffer, B> where
B: Send,
impl<'handle, 'invoker, 'buffer, B> Sync for LockedReadHandle<'handle, 'invoker, 'buffer, B> where
B: Sync,
impl<'handle, 'invoker, 'buffer, B> Unpin for LockedReadHandle<'handle, 'invoker, 'buffer, B>
impl<'handle, 'invoker, 'buffer, B> !UnwindSafe for LockedReadHandle<'handle, 'invoker, 'buffer, B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more