pub struct ByteReservation { /* private fields */ }Expand description
Not Clone: exactly one owner releases each charge, including during unwind. Move this with the allocated buffer; do not drop it while retaining data.
Implementations§
Source§impl ByteReservation
impl ByteReservation
Sourcepub fn resize(&mut self, bytes: usize) -> Result<(), ResourceError>
pub fn resize(&mut self, bytes: usize) -> Result<(), ResourceError>
Change the owned byte count, charging or releasing the difference.
§Errors
Returns ResourceError::Exhausted if growing the reservation cannot
be admitted.
Sourcepub fn split(&mut self, bytes: usize) -> Result<Self, ResourceError>
pub fn split(&mut self, bytes: usize) -> Result<Self, ResourceError>
Split ownership without releasing or charging the same bytes twice.
§Errors
Returns ResourceError::InvalidOwnership if bytes exceeds the
owned amount.
Sourcepub fn transfer(
&mut self,
destination: &ByteBudget,
) -> Result<(), ResourceError>
pub fn transfer( &mut self, destination: &ByteBudget, ) -> Result<(), ResourceError>
Transfer a live charge atomically, including shared-parent accounting. Failure leaves the source reservation and all counters unchanged.
§Errors
Returns ResourceError::DifferentTree if destination is in another
tree, or ResourceError::Exhausted if it cannot admit the bytes.
Trait Implementations§
Source§impl Drop for ByteReservation
impl Drop for ByteReservation
Auto Trait Implementations§
impl Freeze for ByteReservation
impl RefUnwindSafe for ByteReservation
impl Send for ByteReservation
impl Sync for ByteReservation
impl Unpin for ByteReservation
impl UnsafeUnpin for ByteReservation
impl UnwindSafe for ByteReservation
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
Mutably borrows from an owned value. Read more