pub trait RelocatableContainer {
// Required methods
unsafe fn new_uninit(capacity: usize) -> Self;
unsafe fn init<T>(&mut self, allocator: &T) -> Result<(), AllocationError>
where T: BaseAllocator;
fn memory_size(capacity: usize) -> usize;
}Expand description
Describes a container which can shared between processes. Since the shared memory is often mapped at a different virtual memory position the underlying constructs must be relocatable in the sense that they should not rely on absolut memory positions.
Required Methods§
Sourceunsafe fn new_uninit(capacity: usize) -> Self
unsafe fn new_uninit(capacity: usize) -> Self
Creates a new uninitialized RelocatableContainer. Before the container can be used the method
RelocatableContainer::init() must be called.
§Safety
- Before the container can be used
RelocatableContainer::init()must be called exactly once.
Sourceunsafe fn init<T>(&mut self, allocator: &T) -> Result<(), AllocationError>where
T: BaseAllocator,
unsafe fn init<T>(&mut self, allocator: &T) -> Result<(), AllocationError>where
T: BaseAllocator,
Initializes an uninitialized RelocatableContainer. It allocates the required memory from
the provided allocator. The allocator must have at least
RelocatableContainer::memory_size() bytes available.
§Safety
- Must be called exactly once before any other method is called.
- Shall be only used when the
RelocatableContainerwas created withRelocatableContainer::new_uninit()
Sourcefn memory_size(capacity: usize) -> usize
fn memory_size(capacity: usize) -> usize
Returns the amount of additional memory the object requires from the
BaseAllocator in the RelocatableContainer::init() call. The returned value
considers the alignment overhead. When implementing this, please use
iceoryx2_bb_elementary::math::unaligned_mem_size().
The whole memory consumption is
core::mem::size_of::<RelocatableContainer>() + RelocatableContainer::memory_size().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.