Skip to main content

BufferLease

Struct BufferLease 

Source
pub struct BufferLease { /* private fields */ }
Expand description

An exclusive writable pool lease. Its initialized length can be shortened after a read, without copying or borrowing the receiver. Drop returns storage to the pool; an I/O backend must retain this owner until its access retires. A lease keeps its backing slab alive even after the pool is dropped.

Implementations§

Source§

impl BufferLease

Source

pub fn truncate(&mut self, length: usize)

Limit the visible initialized prefix. Panics if the requested length exceeds the current prefix.

Source

pub fn freeze(self) -> FrozenBuffer

Transfer this lease into immutable, independently retainable storage. No allocation or payload copy is required.

Trait Implementations§

Source§

impl AsMut<[u8]> for BufferLease

Source§

fn as_mut(&mut self) -> &mut [u8] ⓘ

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for BufferLease

Source§

fn as_ref(&self) -> &[u8] ⓘ

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for BufferLease

Source§

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

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

impl Drop for BufferLease

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
Source§

impl IoBuf for BufferLease

Source§

fn slice(self, range: impl RangeBounds<usize>) -> BufferSlice<Self>
where Self: Sized,

Limit an operation to an owned range without copying its bytes. Panics if the range is outside the initialized buffer.
Source§

impl IoBufMut for BufferLease

Source§

impl ReceiveBuffer for BufferLease

Source§

type Frozen = FrozenBuffer

The read-only, cloneable owner produced by freeze.
Source§

fn truncate(&mut self, length: usize)

Shorten the initialized prefix after a completed receive. Panics if length exceeds the current prefix. This must not move or replace the backing allocation.
Source§

fn freeze(self) -> FrozenBuffer

Consume mutable access and return a read-only owner of the same bytes, without copying them.
Source§

impl Send for BufferLease

Source§

impl Sync for BufferLease

Auto Trait Implementations§

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.