pub struct MemoryGrant { /* private fields */ }Expand description
RAII wrapper for memory allocations.
Automatically releases memory back to the BufferManager when dropped.
Use consume() to transfer ownership without releasing.
Implementations§
Source§impl MemoryGrant
impl MemoryGrant
Sourcepub fn region(&self) -> MemoryRegion
pub fn region(&self) -> MemoryRegion
Returns the memory region of this grant.
Sourcepub fn resize(&mut self, new_size: usize) -> bool
pub fn resize(&mut self, new_size: usize) -> bool
Attempts to resize the grant.
Returns true if the resize succeeded, false if more memory
could not be allocated.
Sourcepub fn split(&mut self, amount: usize) -> Option<MemoryGrant>
pub fn split(&mut self, amount: usize) -> Option<MemoryGrant>
Splits off a portion of this grant into a new grant.
Returns None if the requested amount exceeds the current size.
Sourcepub fn merge(&mut self, other: MemoryGrant)
pub fn merge(&mut self, other: MemoryGrant)
Merges another grant into this one.
Both grants must be for the same region.
§Panics
Panics if the grants are for different regions.
Sourcepub fn consume(self) -> usize
pub fn consume(self) -> usize
Consumes this grant without releasing memory.
Use this to transfer ownership of the memory to another owner. The caller is responsible for eventually releasing the memory.
Sourcepub fn is_consumed(&self) -> bool
pub fn is_consumed(&self) -> bool
Returns whether this grant has been consumed.