Skip to main content

SlotBackend

Trait SlotBackend 

Source
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 (Feature posix-mmap).
  • Iceoryx2SlotAdapter — Iceoryx2-Bridge (optional Feature iceoryx2-bridge).

Required Methods§

Source

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.

Source

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.

Source

fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>

Verwirft einen Loan ohne Commit. Slot wird wieder frei.

§Errors

OutOfBounds oder Lock-Poison.

Source

fn read_slot( &self, handle: SlotHandle, ) -> Result<(SlotHeader, Vec<u8>), SlotError>

Liest Slot-Header + Daten-Bytes (kopiert).

§Errors

OutOfBounds oder Lock-Poison.

Source

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.

Source

fn mark_reader_disconnected(&self, reader_index: u8) -> Result<(), SlotError>

Setzt das reader_index-Bit retroaktiv auf allen Slots (SPDP-Lease-Expiry).

§Errors

Lock-Poison.

Source

fn slot_count(&self) -> Result<usize, SlotError>

Anzahl konfigurierter Slots.

§Errors

Lock-Poison.

Source

fn slot_total_size(&self) -> usize

Gesamt-Slot-Groesse (Header + Daten + Padding); fuer Discovery.

Source

fn slot_capacity(&self) -> usize

Daten-Bereich pro Slot (ohne Header, ohne Padding).

Provided Methods§

Source

fn type_hash(&self) -> Option<[u8; 16]>

Spec §6.1: TYPE_HASH des Topic-Type, falls dem Backend bekannt. None = Backend trackt keinen Hash; Caller muss auf andere Weise (z.B. Discovery) verifizieren. Default: None.

Implementors§

Source§

impl SlotBackend for InMemorySlotAllocator

Available on crate feature std only.
Source§

impl SlotBackend for PosixSlotAllocator