Skip to main content

Lease

Trait Lease 

Source
pub trait Lease: Buf {
    // Required methods
    fn chunks(&self) -> impl Iterator<Item = &[u8]>;
    fn is_fin(&self) -> bool;
    fn release(self);

    // Provided method
    fn set_window(&mut self, window: u64) { ... }
}
Expand description

Unreleased bytes borrowed from a RecvStream by poll_lease, read as a Buf.

Bytes read keep their credit until release, which is how a frame reaches its consumer before the whole of it has arrived. Implementations override Buf::copy_to_bytes to hand out bytes within one chunk without copying.

Required Methods§

Source

fn chunks(&self) -> impl Iterator<Item = &[u8]>

The bytes not yet read, in order, one contiguous chunk at a time, without reading them.

Source

fn is_fin(&self) -> bool

Whether the peer finished the stream right after the leased bytes.

Source

fn release(self)

Return the credit of every byte read so far, by this lease or an earlier one.

Provided Methods§

Source

fn set_window(&mut self, window: u64)

Set the stream’s window, as RecvStream::set_window does, in the same step as the lease is handed back, by release or a drop.

The reader shrinks the window for the bytes it just read, and the credit they return may be granted from the window as the transport builds the grant. A shrink made after the hand back can lose that race, and credit granted cannot be taken back. Ignored by default, for a transport whose streams cannot set a window.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§