Skip to main content

HandshakeGate

Struct HandshakeGate 

Source
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

Source

pub fn new(supported: SupportedVersions) -> Self

A new gate for a connection that has not yet handshaken, accepting SupportedVersions::current.

Source

pub fn is_complete(&self) -> bool

True once a handshake has been accepted.

Source

pub fn accepted_version(&self) -> Option<ProtocolVersion>

The accepted protocol version, once the handshake has completed.

Source

pub fn admit( &mut self, frame: &Frame, ) -> Result<HandshakeOutcome, HandshakeSequenceError>

Feed one inbound frame to the gate.

  • Before completion, a Frame::Handshake is evaluated against the configured SupportedVersions and produces HandshakeOutcome::Accepted or HandshakeOutcome::Rejected.
  • Before completion, any other frame kind is a sequence violation (Err(HandshakeSequenceError)) — the caller must never have dispatched it to request/subscribe/etc. handling; this call is what makes that guarantee enforceable rather than conventional.
  • After completion, client→server frames (crate::frame::CLIENT_TO_SERVER_KINDS minus handshake) are admitted (HandshakeOutcome::Admitted). A stray second handshake is 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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HandshakeGate

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.