Skip to main content

InMemorySlotAllocator

Struct InMemorySlotAllocator 

Source
pub struct InMemorySlotAllocator { /* private fields */ }
Expand description

In-Memory-Slot-Allocator. Vermittelt das gleiche SlotBackend-Interface wie der POSIX-mmap-Backend (posix.rs), aber liegt im Process-Heap — Single-Process-Pub/Sub und Test-Setups ohne mmap-Dep.

Implementations§

Source§

impl InMemorySlotAllocator

Source

pub fn new(segment_id: u64, slot_count: usize, slot_capacity: usize) -> Self

Erzeugt einen neuen Allocator mit slot_count Slots zu je slot_capacity Bytes Daten-Bereich.

Source

pub fn with_type_hash(self, hash: [u8; 16]) -> Self

Spec §6.1: Allocator mit verbundenem Type-Hash. Reader, der gegen diesen Backend liest, prueft den Hash gegen T::TYPE_HASH und droppt bei Mismatch.

Source

pub fn reserve_slot( &self, active_readers_mask: ReaderMask, ) -> Result<SlotHandle, SlotError>

Spec §4.1 reserve_slot. Sucht einen freien Slot (alle aktiven Reader haben gelesen) oder den ersten unbenutzten.

§Errors

NoFreeSlot wenn alle Slots geloant oder unfertig.

Source

pub fn commit_slot( &self, handle: SlotHandle, bytes: &[u8], ) -> Result<u32, SlotError>

Spec §4.1 commit_slot. Schreibt sample-bytes in den Slot und setzt SlotHeader { sn, sample_size, reader_mask=0 }.

§Errors

OutOfBounds, SampleTooLarge, oder Lock-Poison.

Source

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

Spec §4.1 release_slot (kein commit; verwirft Loan).

§Errors

OutOfBounds oder Lock-Poison.

Source

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

Reader-Side: liest Slot-Header + bytes.

§Errors

OutOfBounds.

Source

pub fn mark_read( &self, handle: SlotHandle, reader_index: u8, ) -> Result<(), SlotError>

Reader-Side: setzt reader_index-Bit im reader_mask.

§Errors

OutOfBounds oder Lock-Poison.

Source

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

Spec §5.2 Reader-Disconnect retroaktiv.

Wird vom Caller (SPDP-Lease-Expiry-Hook) gerufen wenn ein Reader gestorben ist. Setzt sein Bit auf allen Slots, damit der Slot-Allocator ihn als “hat gelesen” sieht und belegte Slots wieder freigibt.

§Errors

Lock-Poison.

Source

pub fn slot_capacity(&self) -> usize

Slot-Capacity (data-Bereich; ohne Header).

Source

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

Anzahl konfigurierter Slots.

Source

pub fn slot_total_size(&self) -> usize

Berechnet die Gesamt-Slot-Groesse (Header + Daten, gepaddet auf 64-byte Cache-Line) — fuer SEDP-Discovery.

Trait Implementations§

Source§

impl SlotBackend for InMemorySlotAllocator

Available on crate feature std only.
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. Read more
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. Read more
Source§

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

Verwirft einen Loan ohne Commit. Slot wird wieder frei. Read more
Source§

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

Liest Slot-Header + Daten-Bytes (kopiert). Read more
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). Read more
Source§

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

Setzt das reader_index-Bit retroaktiv auf allen Slots (SPDP-Lease-Expiry). Read more
Source§

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

Anzahl konfigurierter Slots. Read more
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).
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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V