psp_net/socket/
state.rs

1//! Socket states
2//!
3//! psp-net sockets implement the Type State Pattern, and here are defined
4//! the different possible states of this crate's sockets.
5//!
6//! Note that not all sockets may implement all of these states.
7
8use core::fmt::Debug;
9
10/// Trait describing the state of a socket
11pub trait SocketState: Debug {}
12
13/// Socket is in an unbound state
14#[derive(Debug)]
15pub struct Unbound;
16impl SocketState for Unbound {}
17
18/// Socket is in a bound state
19#[derive(Debug)]
20pub struct Bound;
21impl SocketState for Bound {}
22
23/// Socket is in a connected state
24#[derive(Debug)]
25pub struct Connected;
26impl SocketState for Connected {}
27
28/// Socket is not ready to send or receive data
29#[derive(Debug)]
30pub struct NotReady;
31impl SocketState for NotReady {}
32
33/// Socket is ready to send or receive data
34#[derive(Debug)]
35pub struct Ready;
36impl SocketState for Ready {}