Skip to main content

BatchLease

Struct BatchLease 

Source
pub struct BatchLease<B: Batch> { /* private fields */ }
Expand description

A batch whose retained bytes are charged to an execution context.

The charge is released only when the lease is dropped, keeping accounting aligned with the batch’s actual lifetime.

Implementations§

Source§

impl<B: Batch> BatchLease<B>

Source

pub fn try_new( batch: B, context: &ExecutionContext, ) -> Result<Self, MemoryBudgetError>

Charges the batch’s retained bytes and creates a lease.

§Errors

Returns MemoryBudgetError::Exhausted when existing live batches and this batch would exceed the context budget.

Source

pub fn try_from_reservation( batch: B, reservation: MemoryReservation, ) -> Result<Self, MemoryBudgetError>

Creates a lease from capacity reserved before consuming input.

§Errors

Returns MemoryBudgetError::Exhausted if the batch retained more than the producer reserved before advancing its source.

Source

pub fn try_from_reservation_recycling( batch: B, reservation: MemoryReservation, recycler: Arc<BatchBufferPool<B>>, ) -> Result<Self, MemoryBudgetError>

Creates a lease that returns its batch capacity and memory charge to a bounded pool when dropped. The producer transfers exclusive ownership; consumers share Arc<BatchLease<B>> so the charge cannot be detached.

§Errors

Returns MemoryBudgetError::Exhausted if the batch retained more than the producer reserved before advancing its source.

Source

pub fn batch(&self) -> &B

Borrows the retained batch.

Trait Implementations§

Source§

impl<B: Batch + Debug> Debug for BatchLease<B>

Source§

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

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

impl<B: Batch> Drop for BatchLease<B>

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<B> Freeze for BatchLease<B>
where LeaseBatch<B>: Freeze, Option<Arc<BatchBufferPool<B>>>: Freeze,

§

impl<B> RefUnwindSafe for BatchLease<B>

§

impl<B> Send for BatchLease<B>
where LeaseBatch<B>: Send, Option<Arc<BatchBufferPool<B>>>: Send,

§

impl<B> Sync for BatchLease<B>
where LeaseBatch<B>: Sync, Option<Arc<BatchBufferPool<B>>>: Sync,

§

impl<B> Unpin for BatchLease<B>
where LeaseBatch<B>: Unpin, Option<Arc<BatchBufferPool<B>>>: Unpin,

§

impl<B> UnsafeUnpin for BatchLease<B>
where LeaseBatch<B>: UnsafeUnpin, Option<Arc<BatchBufferPool<B>>>: UnsafeUnpin,

§

impl<B> UnwindSafe for BatchLease<B>
where LeaseBatch<B>: UnwindSafe, Option<Arc<BatchBufferPool<B>>>: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.