1use embassy_net::tcp;
2use embassy_sync::channel::TryReceiveError;
3
4pub type SocketResult<T> = Result<T, SocketErr>;
6
7#[derive(Debug)]
9pub enum SocketErr {
10 TcpError(tcp::Error),
12 ConnectError(tcp::ConnectError),
14 TryReceiveError(TryReceiveError),
16 AcceptError(tcp::AcceptError),
18}
19
20impl SocketErr {
22 #[inline]
25 pub fn no_route() -> Self {
26 Self::ConnectError(tcp::ConnectError::NoRoute)
27 }
28}
29
30impl From<tcp::Error> for SocketErr {
32 #[inline]
33 fn from(value: tcp::Error) -> Self {
34 Self::TcpError(value)
35 }
36}
37
38impl From<tcp::ConnectError> for SocketErr {
40 #[inline]
41 fn from(value: tcp::ConnectError) -> Self {
42 Self::ConnectError(value)
43 }
44}
45
46impl From<TryReceiveError> for SocketErr {
48 #[inline]
49 fn from(value: TryReceiveError) -> Self {
50 Self::TryReceiveError(value)
51 }
52}
53
54impl From<tcp::AcceptError> for SocketErr {
56 #[inline]
57 fn from(value: tcp::AcceptError) -> Self {
58 Self::AcceptError(value)
59 }
60}