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 providerRequired Methods§
Sourcefn alloc(&self, layout: &MemoryLayout) -> ChunkAllocResult
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 >= lenSourcefn free(&self, chunk: &ChunkDescriptor)
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(...)Sourcefn defragment(&self) -> usize
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 chunkSourcefn available(&self) -> usize
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.
Sourcefn layout_for(&self, layout: MemoryLayout) -> Result<MemoryLayout, ZLayoutError>
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