Skip to main content

HalfGuard

Struct HalfGuard 

Source
pub struct HalfGuard<'a, DIR, T: Copy, const N: usize> { /* private fields */ }
Expand description

RAII guard for half-buffer access in a circular DMA transfer.

Holds an &'b mut reborrow of the parent CircRead / CircWrite, so a second half_guard call is rejected by the borrow checker until this guard is dropped.

The DIR parameter is one of Read / Write and selects which cache op is emitted at construction (DCB-00 §5 transition row for DeviceActiveCirc<DIR> HalfGuard).

Implementations§

Source§

impl<'a, DIR, T: Copy, const N: usize> HalfGuard<'a, DIR, T, N>

Source

pub fn as_slice(&self) -> &[T]

Read-only view of the guarded half.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Mutable view of the guarded half.

Source

pub fn half(&self) -> Half

Which half this guard exposes.

Source§

impl<'a, T: Copy, const N: usize> HalfGuard<'a, Read, T, N>

Direction-specific release for HalfGuard<Read, _, _>.

Per DCB-00 §5 (DCB-01b-A 2026-05-03 amendment) the Read direction’s cache op fires at release, not at construction: the CPU is the producer; cleaning before the writes would publish stale data. The clean here publishes the just-completed CPU writes before the engine wraps to this half on its next pass.

Source

pub fn release<C: DcaCache>( self, ctx: &mut DcaCacheCtx<'_, C>, current_half: Half, ) -> Result<(), HalfGuardOverrun>

Release the guard. Emits DcaCache::clean over the guarded half’s extent (the cache op for the Read direction; publishes CPU writes), then performs the INV-D7 stream-position checkpoint.

current_half is the half the DMA engine is currently servicing; the caller reads it from NDTR / LIVR / etc. immediately before this call. If the DMA has crossed into the half this guard exposes (i.e. current_half == self.half), the post-condition check fires per DCB-00 §6 INV-D7: panic! in debug_assertions, error return in release.

Source§

impl<'a, T: Copy, const N: usize> HalfGuard<'a, Write, T, N>

Direction-specific release for HalfGuard<Write, _, _>.

Per DCB-00 §5 the Write direction’s cache op fires at construction (invalidate over the inactive half). release performs only the INV-D7 stream-position checkpoint — the CPU has only read; no dirty lines need publishing.

Source

pub fn release<C: DcaCache>( self, _ctx: &mut DcaCacheCtx<'_, C>, current_half: Half, ) -> Result<(), HalfGuardOverrun>

Release the guard. No cache op (the entry-side invalidate already drained stale lines). Performs the INV-D7 stream-position checkpoint.

_ctx is unused for Write direction (kept for symmetry with HalfGuard<Read>::release).

Auto Trait Implementations§

§

impl<'a, DIR, T, const N: usize> !RefUnwindSafe for HalfGuard<'a, DIR, T, N>

§

impl<'a, DIR, T, const N: usize> !UnwindSafe for HalfGuard<'a, DIR, T, N>

§

impl<'a, DIR, T, const N: usize> Freeze for HalfGuard<'a, DIR, T, N>

§

impl<'a, DIR, T, const N: usize> Send for HalfGuard<'a, DIR, T, N>
where DIR: Send, T: Send,

§

impl<'a, DIR, T, const N: usize> Sync for HalfGuard<'a, DIR, T, N>
where DIR: Sync, T: Send,

§

impl<'a, DIR, T, const N: usize> Unpin for HalfGuard<'a, DIR, T, N>
where DIR: Unpin,

§

impl<'a, DIR, T, const N: usize> UnsafeUnpin for HalfGuard<'a, DIR, T, N>

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.