pub struct DCache<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> { /* private fields */ }Implementations§
Source§impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> DCache<CHUNK_COUNT, CHUNK_SIZE>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a fixed-size cache of payload chunks.
CHUNK_COUNT must be a power of two.
Sourcepub fn allocate(&self) -> u32
pub fn allocate(&self) -> u32
Allocate a chunk index for a new payload (ring buffer style).
This wraps around, so callers must use flow control (Fctl) to ensure chunks are not overwritten before consumers are done with them.
Sourcepub fn write_chunk(
&self,
chunk: u32,
payload: &[u8],
) -> Result<usize, TangoError>
pub fn write_chunk( &self, chunk: u32, payload: &[u8], ) -> Result<usize, TangoError>
Write payload bytes into a chunk, truncating to the chunk size.
Sourcepub fn read_chunk(
&self,
chunk: u32,
size: usize,
) -> Result<DcacheView<'_, CHUNK_SIZE>, TangoError>
pub fn read_chunk( &self, chunk: u32, size: usize, ) -> Result<DcacheView<'_, CHUNK_SIZE>, TangoError>
Read a view of a chunk with the provided size limit.
Sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
Return the configured chunk size in bytes.
Trait Implementations§
Auto Trait Implementations§
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> !Freeze for DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> !RefUnwindSafe for DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Send for DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Sync for DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Unpin for DCache<CHUNK_COUNT, CHUNK_SIZE>
impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> UnwindSafe for DCache<CHUNK_COUNT, CHUNK_SIZE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more