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
impl Cm
Sourcepub fn new(model: DeviceModel, activity_seed: Uuid) -> Cm
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.
Sourcepub fn context(&self) -> Option<&ArContext>
pub fn context(&self) -> Option<&ArContext>
The current AR’s negotiated context (parameters, layout, …), if one is established.
Sourcepub fn next_deadline(&self) -> Option<Instant>
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.
Sourcepub fn set_im(&mut self, im0: Im0, store: ImStore)
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.
Sourcepub fn im_store(&self) -> &ImStore
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).
Sourcepub fn handle_datagram(
&mut self,
buf: &[u8],
from: SocketAddr,
now: Instant,
) -> Result<CmOutput, RpcError>
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.