pub struct RawAllocation {
    pub base_ptr: NonNull<u8>,
    pub size: usize,
}
Expand description

Represents a contiguous piece of a single allocation with some layout. May be wholly or partially uninitialized.

This exists as a convenient way to get access to a type implementing Slab when dealing with your own raw allocations/buffers if you don’t want to or cannot implement Slab for another native type.

Fields

base_ptr: NonNull<u8>

A pointer to the base address of the allocation

size: usize

The size of the allocation in bytes

Implementations

Create a new RawAllocation from a pointer and size.

Safety

This function is safe in and of itself, as nothing will be done with the pointer and size upon creation.

Asserts that we are uniquely borrowing the memory range represented by self for the duration of the borrow, giving us a BorrowedRawAllocation which implements Slab.

Safety

Using this method makes some strong guarantees about the contained base_ptr and size for the duration of the borrow. See the safety documentation for the Slab trait for a list of the guarantees you must make to use this method.

Also see the top-level safety documentation

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

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