Skip to main content

Cm

Struct Cm 

Source
pub struct Cm { /* private fields */ }
Expand description

RPC datagram <-> AR glue: parses the DCE-RPC/NDR/PNIO envelope of an incoming UDP datagram, feeds the pure Ar state machine the resulting Event, and wraps its Actions back into complete RPC PDUs — byte-exact against the golden p-net <-> CPU capture. Also owns the small response cache (a retransmitted request is answered with the identical cached bytes instead of re-running the AR machine) and the call sequence number / controller address used for our outgoing ApplicationReady calls.

Implementations§

Source§

impl Cm

Source

pub fn new(model: DeviceModel, activity_seed: Uuid) -> Cm

A fresh Context Manager for model, idle (no AR). activity_seed is the activity UUID used for calls this device places to the controller (ApplicationReady); it should be stable across the device’s lifetime.

Source

pub fn state(&self) -> ArState

The AR’s current lifecycle state.

Source

pub fn context(&self) -> Option<&ArContext>

The current AR’s negotiated context (parameters, layout, …), if one is established.

Source

pub fn next_deadline(&self) -> Option<Instant>

The next time the caller must call Cm::tick (a pending timeout), or None if nothing is outstanding.

Source

pub fn set_im(&mut self, im0: Im0, store: ImStore)

Replace the device identity answered by I&M0 reads and the writable I&M1-3 store (e.g. once loaded from config/a backing file at startup). Until called, Cm answers with Im0::default() and blank I&M1-3 records.

Source

pub fn im_store(&self) -> &ImStore

The current I&M1-3 store (e.g. so the application can read back tag function/location after a controller Write).

Source

pub fn handle_datagram( &mut self, buf: &[u8], from: SocketAddr, now: Instant, ) -> Result<CmOutput, RpcError>

Parse one incoming UDP datagram and drive the AR machine, returning the PDUs to send and the AR notifications to report. RPC envelope errors (RpcHeader::parse, NdrRequest::parse/NdrResponse::parse, a foreign interface UUID) propagate to the caller to log and drop; PNIO-block-level parse failures are answered in-band with the appropriate PNIO status instead.

Source

pub fn tick(&mut self, now: Instant) -> CmOutput

Drive the AR machine’s timers (activity / ApplicationReady retry) and wrap any resulting retry call or notification.

Source

pub fn abort(&mut self, reason: AbortReason, now: Instant) -> CmOutput

Force the AR to Idle for an externally-observed reason (e.g. the RT runner’s consumer watchdog expiring), mapping the resulting actions exactly like Cm::tick does. A no-op (no Notify) if the AR is already Idle.

Auto Trait Implementations§

§

impl Freeze for Cm

§

impl RefUnwindSafe for Cm

§

impl Send for Cm

§

impl Sync for Cm

§

impl Unpin for Cm

§

impl UnsafeUnpin for Cm

§

impl UnwindSafe for Cm

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 = !

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.