pub enum ConnectionState {
Connecting,
Authenticating,
Active,
Closing,
Closed,
}Expand description
Connection-level lifecycle states enforced by the protocol.
Variants§
Connecting
Waiting for the client Connect frame.
Authenticating
Waiting for the server ConnectAck or ConnectError frame.
Active
Handshake complete; application and keepalive frames may flow.
Closing
Disconnect has been sent; waiting for the peer’s Disconnect acknowledgement.
Closed
Connection is closed and accepts no further frames.
Implementations§
Source§impl ConnectionState
impl ConnectionState
Sourcepub fn validate_frame_type(
self,
frame_type: FrameType,
) -> Result<(), ProtocolError>
pub fn validate_frame_type( self, frame_type: FrameType, ) -> Result<(), ProtocolError>
Validate that a frame type is accepted in this state.
Unknown frame types are forward-compatible and are allowed to pass through lifecycle validation after codec length-delimited skipping.
§Errors
Returns ProtocolError::InvalidStateTransition when frame_type is not
accepted by this state.
Sourcepub fn transition(self, frame: &Frame) -> Result<Self, ProtocolError>
pub fn transition(self, frame: &Frame) -> Result<Self, ProtocolError>
Validate a frame and return the next lifecycle state.
§Errors
Returns ProtocolError::InvalidStream for invalid stream placement and
ProtocolError::InvalidStateTransition for out-of-sequence frames.
Sourcepub fn transition_frame_type(
self,
frame_type: FrameType,
) -> Result<Self, ProtocolError>
pub fn transition_frame_type( self, frame_type: FrameType, ) -> Result<Self, ProtocolError>
Validate a frame type and return the next lifecycle state.
§Errors
Returns ProtocolError::InvalidStateTransition when frame_type is not
accepted by this state.
Sourcepub fn handle_frame(
self,
frame: &Frame,
) -> Result<LifecycleAction, ProtocolError>
pub fn handle_frame( self, frame: &Frame, ) -> Result<LifecycleAction, ProtocolError>
Validate and handle a frame, returning the next state and any protocol response.
Active Ping frames produce a Pong response on stream 0. This function does not perform transport I/O.
§Errors
Returns ProtocolError::InvalidStream for invalid stream placement and
ProtocolError::InvalidStateTransition for out-of-sequence frames.
Trait Implementations§
Source§impl Clone for ConnectionState
impl Clone for ConnectionState
Source§fn clone(&self) -> ConnectionState
fn clone(&self) -> ConnectionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ConnectionState
Source§impl Debug for ConnectionState
impl Debug for ConnectionState
impl Eq for ConnectionState
Source§impl PartialEq for ConnectionState
impl PartialEq for ConnectionState
Source§fn eq(&self, other: &ConnectionState) -> bool
fn eq(&self, other: &ConnectionState) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ConnectionState
Auto Trait Implementations§
impl Freeze for ConnectionState
impl RefUnwindSafe for ConnectionState
impl Send for ConnectionState
impl Sync for ConnectionState
impl Unpin for ConnectionState
impl UnsafeUnpin for ConnectionState
impl UnwindSafe for ConnectionState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.