pub struct SizeClassInfo {
pub block_size: usize,
pub max_blocks: usize,
pub div_mult: u32,
pub class: usize,
}Expand description
Bundles all the per-class constants that are computed separately in the individual lookup functions — convenient when a consumer needs multiple fields for the same class without repeated calls.
Fields§
§block_size: usizeBlock size in bytes for this class.
max_blocks: usizeMaximum blocks per 64 KiB page.
div_mult: u32Lemire reciprocal multiplier for block_index_in_page.
class: usize0-based class index.
Implementations§
Source§impl SizeClassInfo
impl SizeClassInfo
Sourcepub const fn for_class(class: usize) -> Option<SizeClassInfo>
pub const fn for_class(class: usize) -> Option<SizeClassInfo>
Returns the metadata for class class, or None if out of range.
Sourcepub const fn for_size(size: usize) -> Option<SizeClassInfo>
pub const fn for_size(size: usize) -> Option<SizeClassInfo>
Returns the metadata for the class that serves size, or None
when size > MAX_SMALL_ALLOC_SIZE.
Sourcepub const fn block_index(&self, offset: usize) -> usize
pub const fn block_index(&self, offset: usize) -> usize
Computes the block index for a page offset using the pre-computed Lemire multiplier.
Sourcepub fn fragmentation_for(&self, requested: usize) -> f64
pub fn fragmentation_for(&self, requested: usize) -> f64
Internal fragmentation for a request of requested bytes served by
this class: (block_size - requested) / block_size, in [0.0, 1.0].
Trait Implementations§
Source§impl Clone for SizeClassInfo
impl Clone for SizeClassInfo
Source§fn clone(&self) -> SizeClassInfo
fn clone(&self) -> SizeClassInfo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SizeClassInfo
Source§impl Debug for SizeClassInfo
impl Debug for SizeClassInfo
impl Eq for SizeClassInfo
Source§impl PartialEq for SizeClassInfo
impl PartialEq for SizeClassInfo
impl StructuralPartialEq for SizeClassInfo
Auto Trait Implementations§
impl Freeze for SizeClassInfo
impl RefUnwindSafe for SizeClassInfo
impl Send for SizeClassInfo
impl Sync for SizeClassInfo
impl Unpin for SizeClassInfo
impl UnsafeUnpin for SizeClassInfo
impl UnwindSafe for SizeClassInfo
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