Struct SlotManager

Source
pub struct SlotManager { /* private fields */ }
Expand description

Slot 管理器

Slot 管理器,可以管理和申请特定的 Slot

Implementations§

Source§

impl SlotManager

Source

pub const fn empty() -> SlotManager

创建一个空 Slot Manager,默认为没有空 Slot

随后在 SlotManager::init_empty_slots 中更新

Source

pub const fn new(empty_slots: Range<usize>) -> Self

从 empty slots 创建 Slot Manager

Source

pub const fn init_empty_slots(&mut self, new_slots: Range<usize>)

初始化空的 slot 范围

一般配合 SlotManager::empty 使用

Source

pub fn alloc_slot(&mut self) -> LeafSlot

申请一个新的空 Slot

Source

pub fn alloc_slots(&mut self, num: usize) -> SlotRange

申请多个 slot

返回的是开始位置的 LeafSlot

Source

pub fn extend(&mut self, extend_len: usize)

扩展 SlotManager 的管理大小

§参数
  • extend_len 需要扩展的大小

扩展的方式为从原有的范围的结尾向后增长

Source

pub fn next_range_start(&self) -> usize

获取下一可用范围开始的位置

§返回值

下一个可用范围的开始,可以用于 Self::extend

Source

pub fn available(&self) -> usize

获取 SlotManager 中可用的大小

§返回值
  • [usize] 当前尚未使用的 Slot 数量
Source

pub fn recycle_slot(&mut self, slot: LeafSlot)

回收一个 LeafSlot

LeafSlot 放入回收池中,便于下次申请时复用

§参数

Trait Implementations§

Source§

impl Debug for SlotManager

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for SlotManager

§

impl RefUnwindSafe for SlotManager

§

impl Send for SlotManager

§

impl Sync for SlotManager

§

impl Unpin for SlotManager

§

impl UnwindSafe for SlotManager

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.