ShmProviderBackend

Trait ShmProviderBackend 

Source
pub trait ShmProviderBackend: WithProtocolID {
    // Required methods
    fn alloc(&self, layout: &MemoryLayout) -> ChunkAllocResult;
    fn free(&self, chunk: &ChunkDescriptor);
    fn defragment(&self) -> usize;
    fn available(&self) -> usize;
    fn layout_for(
        &self,
        layout: MemoryLayout,
    ) -> Result<MemoryLayout, ZLayoutError>;
}
Expand description

The provider backend trait

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Implement this interface to create a Zenoh-compatible shared memory provider

Required Methods§

Source

fn alloc(&self, layout: &MemoryLayout) -> ChunkAllocResult

Allocate the chunk of desired size.

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
If successful, the result's chunk size will be >= len
Source

fn free(&self, chunk: &ChunkDescriptor)

Deallocate the chunk.

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
It is guaranteed that chunk's descriptor will correspond to the one returned from alloc(...)
Source

fn defragment(&self) -> usize

Defragment the memory.

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Should return the size of largest defragmented chunk
Source

fn available(&self) -> usize

Bytes available for use

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Source

fn layout_for(&self, layout: MemoryLayout) -> Result<MemoryLayout, ZLayoutError>

Check and calculate suitable layout for layout.

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Depending on the implementation, backend may relayout allocations for bigger layouts. This method is used to: - validate, if the provided layout can be used with this backend - adopt the layout for backend capabilities

Implementors§