Skip to main content

RingLayout

Struct RingLayout 

Source
pub struct RingLayout {
    pub slot_count: u32,
    pub slot_bytes: u32,
}
Expand description

Memory layout of a single-writer, many-reader frame ring.

Layout (all integers little-endian):

[ ring header  ]  HEADER_LEN bytes: magic, version, slot_count, slot_bytes
[ slot 0       ]  SLOT_HEADER_LEN + slot_bytes + SLOT_TRAILER_LEN
[ slot 1       ]
  ...

Each slot is seq_begin:u64 | byte_len:u32 | _pad:u32 | <slot_bytes data> | seq_end:u64. The writer stores seq_begin, then the data and length, then seq_end; a reader loads seq_end, copies the data, then re-checks seq_begin and seq_end against the descriptor’s seq. If either differs the read was torn by a slot recycle and is discarded. Sizing slot_count above the number of concurrent consumers plus their read latency makes torn reads rare.

Fields§

§slot_count: u32§slot_bytes: u32

Capacity of one slot’s pixel region (the largest frame the ring holds).

Implementations§

Source§

impl RingLayout

Source

pub const MAGIC: u32 = 0x4144_5631

“ADV1” — ADOS vision ring, version 1.

Source

pub const VERSION: u16 = 1

Source

pub const HEADER_LEN: usize = 16

Source

pub const SLOT_HEADER_LEN: usize = 16

seq_begin (u64) + byte_len (u32) + pad (u32).

Source

pub const SLOT_TRAILER_LEN: usize = 8

seq_end (u64).

Source

pub fn for_frame( slot_count: u32, width: u32, height: u32, format: FrameFormat, ) -> Self

Size a ring that holds frames up to width x height in format.

Source

pub fn slot_stride(&self) -> usize

Source

pub fn total_len(&self) -> usize

Total bytes the shared region must provide.

Source

pub fn validate(&self) -> Result<(), RingError>

Validate the layout against the on-disk header’s field widths. The header stores slot_count in two bytes, so a layout above MAX_SLOT_COUNT would truncate on write and the reader’s header-derived layout would name a different slot than the writer used. Callers validate at ring-creation / engine startup so a misconfigured depth is rejected loudly rather than silently truncated.

Source

pub fn write_header(&self, region: &mut [u8]) -> Result<(), RingError>

Write the ring header at the front of a freshly created region. Rejects a slot_count the two-byte header field cannot represent so the writer’s slot math (seq % slot_count) can never diverge from a reader that re-derives the layout from the header.

Source

pub fn read_header(region: &[u8]) -> Option<RingLayout>

Read the layout a writer recorded in a region’s header.

Trait Implementations§

Source§

impl Clone for RingLayout

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RingLayout

Source§

impl Debug for RingLayout

Source§

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

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

impl Eq for RingLayout

Source§

impl PartialEq for RingLayout

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RingLayout

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more