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>
impl<B: Batch> BatchLease<B>
Sourcepub fn try_new(
batch: B,
context: &ExecutionContext,
) -> Result<Self, MemoryBudgetError>
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.
Sourcepub fn try_from_reservation(
batch: B,
reservation: MemoryReservation,
) -> Result<Self, MemoryBudgetError>
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.
Sourcepub fn try_from_reservation_recycling(
batch: B,
reservation: MemoryReservation,
recycler: Arc<BatchBufferPool<B>>,
) -> Result<Self, MemoryBudgetError>
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.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for BatchLease<B>
impl<B> RefUnwindSafe for BatchLease<B>
impl<B> Send for BatchLease<B>
impl<B> Sync for BatchLease<B>
impl<B> Unpin for BatchLease<B>
impl<B> UnsafeUnpin for BatchLease<B>
impl<B> UnwindSafe for BatchLease<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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