Skip to main content

SlabBox

Struct SlabBox 

Source
pub struct SlabBox<T, LOCK, const SLAB_SIZE: usize>
where LOCK: LockTrait,
{ /* private fields */ }
Expand description

A smart pointer to an object of type T allocated in a slab.

When this struct goes out of scope, the memory is automatically returned to the originating slab.

Implementations§

Source§

impl<T, LOCK, const SLAB_SIZE: usize> SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: LockTrait,

Source

pub fn new(ptr: NonNull<T>) -> Self

Wraps a raw pointer into a SlabBox.

§Safety
  • The ptr must be a valid, allocated slot from a Slab with SLAB_SIZE.
Source

pub fn as_ptr(&self) -> *mut T

Returns the raw pointer to the underlying data.

Trait Implementations§

Source§

impl<T, LOCK, const SLAB_SIZE: usize> Deref for SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: LockTrait,

Source§

fn deref(&self) -> &Self::Target

Provides immutable access to the underlying data.

Source§

type Target = T

The resulting type after dereferencing.
Source§

impl<T, LOCK, const SLAB_SIZE: usize> DerefMut for SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: LockTrait,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Provides mutable access to the underlying data.

Source§

impl<T, LOCK, const SLAB_SIZE: usize> Drop for SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: LockTrait,

Source§

fn drop(&mut self)

Automatically returns the memory to the slab system.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T, LOCK, const SLAB_SIZE: usize> Send for SlabBox<T, LOCK, SLAB_SIZE>
where T: Send, LOCK: LockTrait + Sync,

Source§

impl<T, LOCK, const SLAB_SIZE: usize> Sync for SlabBox<T, LOCK, SLAB_SIZE>
where T: Sync, LOCK: LockTrait + Sync,

Auto Trait Implementations§

§

impl<T, LOCK, const SLAB_SIZE: usize> Freeze for SlabBox<T, LOCK, SLAB_SIZE>

§

impl<T, LOCK, const SLAB_SIZE: usize> RefUnwindSafe for SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, LOCK, const SLAB_SIZE: usize> Unpin for SlabBox<T, LOCK, SLAB_SIZE>
where LOCK: Unpin,

§

impl<T, LOCK, const SLAB_SIZE: usize> UnsafeUnpin for SlabBox<T, LOCK, SLAB_SIZE>

§

impl<T, LOCK, const SLAB_SIZE: usize> UnwindSafe for SlabBox<T, LOCK, SLAB_SIZE>
where T: RefUnwindSafe, LOCK: UnwindSafe,

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

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

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.