Skip to main content

DCache

Struct DCache 

Source
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>

Source

pub fn new() -> Self

Create a fixed-size cache of payload chunks.

CHUNK_COUNT must be a power of two.

Source

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.

Source

pub fn capacity(&self) -> usize

Returns the number of chunks in the cache.

Source

pub fn write_chunk( &self, chunk: u32, payload: &[u8], ) -> Result<usize, TangoError>

Write payload bytes into a chunk, truncating to the chunk size.

Source

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.

Source

pub fn chunk_size(&self) -> usize

Return the configured chunk size in bytes.

Trait Implementations§

Source§

impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Debug for DCache<CHUNK_COUNT, CHUNK_SIZE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Default for DCache<CHUNK_COUNT, CHUNK_SIZE>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> UnsafeUnpin 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> 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.