pub trait SlotBackend: Send + Sync {
// Required methods
fn reserve_slot(
&self,
active_readers_mask: ReaderMask,
) -> Result<SlotHandle, SlotError>;
fn commit_slot(
&self,
handle: SlotHandle,
bytes: &[u8],
) -> Result<u32, SlotError>;
fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>;
fn read_slot(
&self,
handle: SlotHandle,
) -> Result<(SlotHeader, Vec<u8>), SlotError>;
fn mark_read(
&self,
handle: SlotHandle,
reader_index: u8,
) -> Result<(), SlotError>;
fn mark_reader_disconnected(
&self,
reader_index: u8,
) -> Result<(), SlotError>;
fn slot_count(&self) -> Result<usize, SlotError>;
fn slot_total_size(&self) -> usize;
fn slot_capacity(&self) -> usize;
// Provided method
fn type_hash(&self) -> Option<[u8; 16]> { ... }
}Expand description
Backend-Trait fuer SHM-Slot-Allocator.
Implementer:
crate::InMemorySlotAllocator— In-Memory-Backend, Default fuer Single-Process-Tests und als Referenz-Implementation.PosixSlotAllocator— POSIX-shm_open+mmap, Cross-Process-Same-Host (Featureposix-mmap).Iceoryx2SlotAdapter— Iceoryx2-Bridge (optional Featureiceoryx2-bridge).
Required Methods§
Sourcefn reserve_slot(
&self,
active_readers_mask: ReaderMask,
) -> Result<SlotHandle, SlotError>
fn reserve_slot( &self, active_readers_mask: ReaderMask, ) -> Result<SlotHandle, SlotError>
Reserviert einen freien Slot. Caller schreibt danach via
commit_slot und veroeffentlicht damit das Sample.
§Errors
NoFreeSlot wenn alle Slots geloant oder unfertig.
Sourcefn commit_slot(
&self,
handle: SlotHandle,
bytes: &[u8],
) -> Result<u32, SlotError>
fn commit_slot( &self, handle: SlotHandle, bytes: &[u8], ) -> Result<u32, SlotError>
Schreibt sample-bytes in den Slot und setzt SlotHeader
{ sn, sample_size, reader_mask=0 }. Liefert die SN.
§Errors
OutOfBounds, SampleTooLarge, oder Lock-Poison.
Sourcefn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
Sourcefn read_slot(
&self,
handle: SlotHandle,
) -> Result<(SlotHeader, Vec<u8>), SlotError>
fn read_slot( &self, handle: SlotHandle, ) -> Result<(SlotHeader, Vec<u8>), SlotError>
Sourcefn mark_read(
&self,
handle: SlotHandle,
reader_index: u8,
) -> Result<(), SlotError>
fn mark_read( &self, handle: SlotHandle, reader_index: u8, ) -> Result<(), SlotError>
Setzt das Bit reader_index im reader_mask des Slots
(Reader hat gelesen).
§Errors
OutOfBounds oder Lock-Poison.
Sourcefn slot_count(&self) -> Result<usize, SlotError>
fn slot_count(&self) -> Result<usize, SlotError>
Sourcefn slot_total_size(&self) -> usize
fn slot_total_size(&self) -> usize
Gesamt-Slot-Groesse (Header + Daten + Padding); fuer Discovery.
Sourcefn slot_capacity(&self) -> usize
fn slot_capacity(&self) -> usize
Daten-Bereich pro Slot (ohne Header, ohne Padding).
Provided Methods§
Implementors§
impl SlotBackend for InMemorySlotAllocator
Available on crate feature
std only.