Skip to main content

SizeClassInfo

Struct SizeClassInfo 

Source
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: usize

Block size in bytes for this class.

§max_blocks: usize

Maximum blocks per 64 KiB page.

§div_mult: u32

Lemire reciprocal multiplier for block_index_in_page.

§class: usize

0-based class index.

Implementations§

Source§

impl SizeClassInfo

Source

pub const fn for_class(class: usize) -> Option<SizeClassInfo>

Returns the metadata for class class, or None if out of range.

Source

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.

Source

pub const fn block_index(&self, offset: usize) -> usize

Computes the block index for a page offset using the pre-computed Lemire multiplier.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Copy for SizeClassInfo

Source§

impl Debug for SizeClassInfo

Source§

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

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

impl Eq for SizeClassInfo

Source§

impl PartialEq for SizeClassInfo

Source§

fn eq(&self, other: &SizeClassInfo) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SizeClassInfo

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.