pub struct HandshakeGate { /* private fields */ }Expand description
Drives the per-connection handshake state machine.
Deliberately not Clone: the gate’s entire guarantee is that its state
only ever moves forward for one connection. A copy of a completed gate
would admit requests on a connection that never handshook, and a copy of
an earlier state could be restored after a violation closed the original.
Implementations§
Source§impl HandshakeGate
impl HandshakeGate
Sourcepub fn new(supported: SupportedVersions) -> Self
pub fn new(supported: SupportedVersions) -> Self
A new gate for a connection that has not yet handshaken, accepting
SupportedVersions::current.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
True once a handshake has been accepted.
Sourcepub fn accepted_version(&self) -> Option<ProtocolVersion>
pub fn accepted_version(&self) -> Option<ProtocolVersion>
The accepted protocol version, once the handshake has completed.
Sourcepub fn admit(
&mut self,
frame: &Frame,
) -> Result<HandshakeOutcome, HandshakeSequenceError>
pub fn admit( &mut self, frame: &Frame, ) -> Result<HandshakeOutcome, HandshakeSequenceError>
Feed one inbound frame to the gate.
- Before completion, a
Frame::Handshakeis evaluated against the configuredSupportedVersionsand producesHandshakeOutcome::AcceptedorHandshakeOutcome::Rejected. - Before completion, any other frame kind is a sequence violation
(
Err(HandshakeSequenceError)) — the caller must never have dispatched it torequest/subscribe/etc. handling; this call is what makes that guarantee enforceable rather than conventional. - After completion, client→server frames
(
crate::frame::CLIENT_TO_SERVER_KINDSminushandshake) are admitted (HandshakeOutcome::Admitted). A stray secondhandshakeis a sequence violation (the ADR fixes the handshake to “the first application frame”), and a server→client-only kind (response,handshake_ack,subscribe_ack,unsubscribe_ack,event) is a direction violation — it can never be a legal inbound frame on this gate — and closes the gate like any other protocol violation.
Trait Implementations§
Source§impl Debug for HandshakeGate
impl Debug for HandshakeGate
Auto Trait Implementations§
impl Freeze for HandshakeGate
impl RefUnwindSafe for HandshakeGate
impl Send for HandshakeGate
impl Sync for HandshakeGate
impl Unpin for HandshakeGate
impl UnsafeUnpin for HandshakeGate
impl UnwindSafe for HandshakeGate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more