use alloc::vec::Vec;
use crate::allocator::{SlotError, SlotHandle};
use crate::slot::{ReaderMask, SlotHeader};
pub trait SlotBackend: Send + Sync {
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 slot_data_ptr(&self, handle: SlotHandle) -> Result<(*mut u8, usize), SlotError> {
let _ = handle;
Err(SlotError::InPlaceUnsupported)
}
fn commit_in_place(&self, handle: SlotHandle, len: usize) -> Result<u32, SlotError> {
let _ = (handle, len);
Err(SlotError::InPlaceUnsupported)
}
fn read_slot(&self, handle: SlotHandle) -> Result<(SlotHeader, Vec<u8>), SlotError>;
fn slot_read_ptr(&self, handle: SlotHandle) -> Result<(*const u8, usize), SlotError> {
let _ = handle;
Err(SlotError::InPlaceUnsupported)
}
fn next_unread_slot(&self, reader_index: u8) -> Result<Option<SlotHandle>, SlotError> {
let _ = reader_index;
Ok(None)
}
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;
fn type_hash(&self) -> Option<[u8; 16]> {
None
}
fn notify_generation(&self) -> u64 {
0
}
fn wait_for_change(&self, last: u64, timeout: core::time::Duration) {
let _ = (last, timeout);
}
}