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.