RelocatableContainer

Trait RelocatableContainer 

Source
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§

Source

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
Source

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
Source

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.

Implementors§