Trait SocketState

Source
pub trait SocketState<const C: usize>: Send {
    // Required methods
    fn session_id(&self) -> &str;
    fn run(
        &mut self,
        components: SocketComponents<C>,
    ) -> Result<(), SessionError>;
    fn stop(&mut self) -> Result<(), SessionError>;
    fn incoming_segment(
        &mut self,
        id: &SegmentId,
        ind: SeqIndicator,
    ) -> Result<(), SessionError>;
    fn incoming_retransmission_request(
        &mut self,
        request: SegmentRequest<C>,
    ) -> Result<(), SessionError>;
    fn incoming_acknowledged_frames(
        &mut self,
        ack: FrameAcknowledgements<C>,
    ) -> Result<(), SessionError>;
    fn frame_complete(&mut self, id: u32) -> Result<(), SessionError>;
    fn frame_emitted(&mut self, id: u32) -> Result<(), SessionError>;
    fn frame_discarded(&mut self, id: u32) -> Result<(), SessionError>;
    fn segment_sent(&mut self, segment: &Segment) -> Result<(), SessionError>;
}
Expand description

Abstraction of the SessionSocket state.

Required Methods§

Source

fn session_id(&self) -> &str

Gets ID of this Session.

Source

fn run(&mut self, components: SocketComponents<C>) -> Result<(), SessionError>

Starts the necessary processes inside the state. Should be idempotent if called multiple times.

Source

fn stop(&mut self) -> Result<(), SessionError>

Stops processes inside the state for the given direction.

Source

fn incoming_segment( &mut self, id: &SegmentId, ind: SeqIndicator, ) -> Result<(), SessionError>

Called when the Socket receives a new segment from Downstream. When the error is returned, the incoming segment is not passed Upstream.

Source

fn incoming_retransmission_request( &mut self, request: SegmentRequest<C>, ) -> Result<(), SessionError>

Called when segment retransmission request is received from Downstream.

Source

fn incoming_acknowledged_frames( &mut self, ack: FrameAcknowledgements<C>, ) -> Result<(), SessionError>

Called when an acknowledgement of frames is received from Downstream.

Source

fn frame_complete(&mut self, id: u32) -> Result<(), SessionError>

Called when a complete Frame has been finalized from segments received from Downstream.

Source

fn frame_emitted(&mut self, id: u32) -> Result<(), SessionError>

Called when a complete Frame emitted to Upstream in-sequence.

Source

fn frame_discarded(&mut self, id: u32) -> Result<(), SessionError>

Called when a frame could not be completed from the segments received from Downstream.

Source

fn segment_sent(&mut self, segment: &Segment) -> Result<(), SessionError>

Called when a segment of a Frame was sent to the Downstream.

Implementors§

Source§

impl<const C: usize> SocketState<C> for AcknowledgementState<C>

Source§

impl<const C: usize> SocketState<C> for Stateless<C>