pub struct TargetHandshake { /* private fields */ }Expand description
Target-side handshake coordinator.
§Idempotent Handshake Retransmission Contract
In lossy UART links, the target’s initial HandshakeResponse may be dropped or
corrupted in flight. When this occurs, the host’s timeout will cause it to retransmit
the initial NegotiateReq with the identical session_id.
Target implementations (e.g. receiver_task) MUST treat repeated NegotiateReq
frames with the active session_id as idempotent retransmissions: the target must
re-emit the cached NegotiateResp frame rather than rejecting the frame as unexpected
or resetting the transport state. If a NegotiateReq arrives with a new session ID,
the target must reset and negotiate the new session.
Implementations§
Source§impl TargetHandshake
impl TargetHandshake
Sourcepub fn new(supported: Vec<ProtocolId>) -> Self
pub fn new(supported: Vec<ProtocolId>) -> Self
Creates a new target handshake handler with the list of supported protocols.
Sourcepub fn supported(&self) -> &[ProtocolId]
pub fn supported(&self) -> &[ProtocolId]
Returns the list of supported protocols.
Sourcepub fn handle_request(
&self,
payload: &[u8],
) -> Result<(Option<ProtocolId>, Vec<u8>), HandshakeError>
pub fn handle_request( &self, payload: &[u8], ) -> Result<(Option<ProtocolId>, Vec<u8>), HandshakeError>
Evaluates an incoming host request payload and generates the serialized response.
Returns (selected_protocol, response_payload).
§Errors
Returns HandshakeError::MalformedPayload if payload cannot be decoded into
a valid [HandshakeRequest].