pub trait IHeap<S: IShape> {
type Ptr: IPtr;
// Required methods
unsafe fn alloc(&mut self, shape: S) -> Self::Ptr;
unsafe fn dealloc(&mut self, ptr: Self::Ptr, shape: S);
unsafe fn memcpy(&mut self, dst: Self::Ptr, src: Self::Ptr, len: usize);
unsafe fn drop_in_place(&mut self, ptr: Self::Ptr, shape: S);
unsafe fn default_in_place(&mut self, ptr: Self::Ptr, shape: S) -> bool;
}Expand description
Heap for memory operations, generic over shape type.
Required Associated Types§
Required Methods§
Sourceunsafe fn alloc(&mut self, shape: S) -> Self::Ptr
unsafe fn alloc(&mut self, shape: S) -> Self::Ptr
Allocate a region for a value of the given shape.
§Safety
The caller must ensure shape is valid for allocation and that any
constraints required by the heap implementation are satisfied.
Sourceunsafe fn dealloc(&mut self, ptr: Self::Ptr, shape: S)
unsafe fn dealloc(&mut self, ptr: Self::Ptr, shape: S)
Deallocate a region.
§Safety
The caller must ensure ptr points to the start of a live allocation
previously returned by alloc, that the allocation corresponds to
shape, and that no bytes in the region are still initialized.
Sourceunsafe fn memcpy(&mut self, dst: Self::Ptr, src: Self::Ptr, len: usize)
unsafe fn memcpy(&mut self, dst: Self::Ptr, src: Self::Ptr, len: usize)
Copy len bytes from src to dst.
§Safety
The caller must ensure both ranges are in-bounds for their allocations,
that src is fully initialized, dst is fully uninitialized, and the
ranges do not overlap.
Sourceunsafe fn drop_in_place(&mut self, ptr: Self::Ptr, shape: S)
unsafe fn drop_in_place(&mut self, ptr: Self::Ptr, shape: S)
Drop the value at ptr and mark the range as uninitialized.
§Safety
The caller must ensure ptr points to a value of type shape, the
value is fully initialized, and the allocation is still live.
Sourceunsafe fn default_in_place(&mut self, ptr: Self::Ptr, shape: S) -> bool
unsafe fn default_in_place(&mut self, ptr: Self::Ptr, shape: S) -> bool
Default-initialize the value at ptr and mark the range as initialized.
Returns false if the shape has no default.
§Safety
The caller must ensure the destination range is uninitialized, in-bounds,
and corresponds to shape.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".