pub struct MasterSession { /* private fields */ }Expand description
Owns the “awaiting response” slot(s) for a master. The master calls
MasterSession::start when it sends a request, and MasterSession::stop
when the response arrives or times out. MasterSession::handle_frame /
MasterSession::handle_error are called by the master’s framing /
framing_error subscription tasks.
Implementations§
Source§impl MasterSession
impl MasterSession
pub fn new() -> Self
Sourcepub fn start(
&self,
key: WaiterKey,
pre_check: Vec<PreCheck>,
) -> Receiver<Result<Framing, ModbusError>>
pub fn start( &self, key: WaiterKey, pre_check: Vec<PreCheck>, ) -> Receiver<Result<Framing, ModbusError>>
Arm a waiter under key. Returns a receiver that resolves with
either the first matching Framing or a rejection reason.
If key already has a waiter (e.g. TID wrap collision), the
previous waiter’s receiver is dropped — equivalent to the caller
calling MasterSession::stop first.
Sourcepub fn stop(&self, key: WaiterKey)
pub fn stop(&self, key: WaiterKey)
Drop the waiter under key without notifying it. Used on timeout,
where the caller has already given up on the receiver.
Sourcepub fn stop_all(&self, err: ModbusError)
pub fn stop_all(&self, err: ModbusError)
Reject every armed waiter with err. Used by handle_error
(framing errors lose transaction context) and on master
close/destroy.
Sourcepub fn handle_frame(&self, frame: Framing)
pub fn handle_frame(&self, frame: Framing)
Push a successfully framed PDU at the session. Looks up the waiter
keyed by frame.adu.transaction (TCP) or WaiterKey::Fifo
(RTU/ASCII). If found, removes it and runs the pre-checks; on the
first failing check, rejects with the corresponding error. On all
checks passing, resolves with the frame. No-op if no waiter matches.
Sourcepub fn handle_error(&self, err: ModbusError)
pub fn handle_error(&self, err: ModbusError)
Push a framing error at the session. Framing errors arrive without transaction context (CRC/LRC failure, bogus MBAP header, etc.), so every in-flight waiter is rejected.