[−][src]Struct alloc_wg::alloc::MemoryBlock
Represents a block of allocated memory returned by an allocator.
Methods
impl MemoryBlock
[src]
pub const unsafe fn new(ptr: NonNull<u8>, layout: Layout) -> Self
[src]
Creates a new MemoryBlock
.
Safety
- The block must be allocated with the same alignment as [
layout.align()
], and - The provided [
layout.size()
] must fall in the rangemin ..= max
, where:min
is the size requested size when allocating the block, andmax
is the size of the memory block.
pub const fn ptr(&self) -> NonNull<u8>
[src]
Acquires the underlying NonNull<u8>
pointer.
pub const fn layout(&self) -> Layout
[src]
Returns the layout describing the memory block.
pub const fn size(&self) -> usize
[src]
Returns the size of the memory block.
pub const fn align(&self) -> usize
[src]
Returns the minimum alignment of the memory block.
pub fn init(&mut self, init: AllocInit)
[src]
Initialize the memory block like specified by init
.
This behaves like calling MemoryBlock::initialize_offset(ptr, layout, 0)
.
pub unsafe fn init_offset(&mut self, init: AllocInit, offset: usize)
[src]
Initialize the memory block like specified by init
at the specified offset
.
This is a no-op for AllocInit::Uninitialized
and writes zeroes for AllocInit::Zeroed
at ptr + offset
until ptr + layout.size()
.
Safety
offset
must be smaller than or equal tosize()
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MemoryBlock
impl Send for MemoryBlock
impl Sync for MemoryBlock
impl Unpin for MemoryBlock
impl UnwindSafe for MemoryBlock
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,