Skip to main content

ReadRequest

Struct ReadRequest 

Source
pub struct ReadRequest<'a> { /* private fields */ }
Expand description

Bytes a suspended task is waiting for.

Put the stream’s bytes from offset in buffer: at least min_len of them, and up to window_len if they are as easy to read. Fewer than min_len is an unexpected end of the stream, and the task fails. Then resume the task.

Implementations§

Source§

impl ReadRequest<'_>

Source

pub fn offset(&self) -> u64

Where in the stream the bytes are wanted.

Source

pub fn min_len(&self) -> usize

The fewest bytes the task can go on with.

Source

pub fn window_len(&self) -> usize

How many bytes the task would like: at least min_len, and never past the end of the stream.

Source

pub fn buffer(&mut self) -> &mut Vec<u8> ⓘ

The buffer to fill. It starts empty; put the bytes in it, replacing what it holds. Its capacity is reused between requests. The request owns it, so a request can be held across an .await, and the task is given the buffer back when the request is dropped.

Source

pub fn fill<R: Read + Seek + ?Sized>(self, src: &mut R) -> Result<()>

Fill the buffer from src, a seekable stream: seek to the offset and read up to window_len bytes. The buffer is not zeroed first.

Trait Implementations§

Source§

impl Debug for ReadRequest<'_>

Source§

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

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

impl Drop for ReadRequest<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for ReadRequest<'a>

§

impl<'a> Forget for ReadRequest<'a>

§

impl<'a> Freeze for ReadRequest<'a>

§

impl<'a> Move for ReadRequest<'a>

§

impl<'a> RefUnwindSafe for ReadRequest<'a>

§

impl<'a> Send for ReadRequest<'a>

§

impl<'a> Sync for ReadRequest<'a>

§

impl<'a> Unpin for ReadRequest<'a>

§

impl<'a> UnsafeUnpin for ReadRequest<'a>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.