psp_net/socket/
state.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Socket states
//!
//! psp-net sockets implement the Type State Pattern, and here are defined
//! the different possible states of this crate's sockets.
//!
//! Note that not all sockets may implement all of these states.

use core::fmt::Debug;

/// Trait describing the state of a socket
pub trait SocketState: Debug {}

/// Socket is in an unbound state
#[derive(Debug)]
pub struct Unbound;
impl SocketState for Unbound {}

/// Socket is in a bound state
#[derive(Debug)]
pub struct Bound;
impl SocketState for Bound {}

/// Socket is in a connected state
#[derive(Debug)]
pub struct Connected;
impl SocketState for Connected {}

/// Socket is not ready to send or receive data
#[derive(Debug)]
pub struct NotReady;
impl SocketState for NotReady {}

/// Socket is ready to send or receive data
#[derive(Debug)]
pub struct Ready;
impl SocketState for Ready {}