• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kaidokert / winc-rs / 23717623340

29 Mar 2026 07:51PM UTC coverage: 79.619% (-0.6%) from 80.259%
23717623340

Pull #142

github

web-flow
Merge 7dad7f631 into dea6e698f
Pull Request #142: Methods for Non-Blocking Features with a Shared Codebase for Sync and Async

38 of 89 new or added lines in 5 files covered. (42.7%)

1 existing line in 1 file now uncovered.

4852 of 6094 relevant lines covered (79.62%)

33061.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.08
/winc-rs/src/stack/stack_error.rs
1
use crate::manager::WifiConnError;
2

3
#[cfg(feature = "experimental-ota")]
4
use crate::manager::OtaUpdateError;
5
use crate::manager::SocketError;
6

7
use embedded_nal::nb;
8

9
#[cfg(feature = "async")]
10
use embedded_io_async;
11

12
/// Stack errors
13
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
14
#[derive(Debug, PartialEq)]
15
pub enum StackError {
16
    WouldBlock,
17
    GeneralTimeout,
18
    /// TCP connection timed out
19
    ConnectTimeout,
20
    RecvTimeout,
21
    SendTimeout,
22
    OutOfSockets,
23
    SocketAlreadyInUse,
24
    CloseFailed,
25
    Unexpected,
26
    DispatchError(crate::errors::CommError),
27
    ConnectSendFailed(crate::errors::CommError),
28
    ReceiveFailed(crate::errors::CommError),
29
    SendSendFailed(crate::errors::CommError),
30
    SendCloseFailed(crate::errors::CommError),
31
    BindFailed(crate::errors::CommError),
32
    WincWifiFail(crate::errors::CommError),
33
    OpFailed(SocketError),
34
    /// DNS lookup timed out
35
    DnsTimeout,
36
    /// Unexpected DNS error
37
    DnsFailed,
38
    /// Operation was attempted in wrong state
39
    InvalidState,
40
    AlreadyConnected,
41
    /// Access point join failed
42
    ApJoinFailed(WifiConnError),
43
    /// Scan operation failed
44
    ApScanFailed(WifiConnError),
45
    // Continue
46
    ContinueOperation,
47
    /// Not found
48
    SocketNotFound,
49
    /// Parameters are not valid.
50
    InvalidParameters,
51
    /// Response from the module is invalid or malformed.
52
    InvalidResponse,
53
    #[cfg(feature = "experimental-ota")]
54
    /// Ota Error
55
    OtaFail(OtaUpdateError),
56
    #[cfg(feature = "async")]
57
    /// Too many concurrent async operations (waker array full)
58
    TooManyWakers,
59
    /// If acquiring resources such as a manager or callback fails.
60
    #[cfg(feature = "async")]
61
    ResourceBusy,
62
}
63

64
impl From<core::convert::Infallible> for StackError {
65
    fn from(_: core::convert::Infallible) -> Self {
×
66
        unreachable!()
×
67
    }
68
}
69

70
impl From<SocketError> for StackError {
71
    fn from(inner: SocketError) -> Self {
×
72
        Self::OpFailed(inner)
×
73
    }
×
74
}
75

76
impl From<crate::errors::CommError> for StackError {
77
    fn from(inner: crate::errors::CommError) -> Self {
3✔
78
        Self::WincWifiFail(inner)
3✔
79
    }
3✔
80
}
81

82
impl From<crate::errors::CommError> for nb::Error<StackError> {
83
    fn from(inner: crate::errors::CommError) -> Self {
×
84
        nb::Error::Other(StackError::WincWifiFail(inner))
×
85
    }
×
86
}
87

88
impl From<core::net::AddrParseError> for StackError {
89
    fn from(_: core::net::AddrParseError) -> Self {
×
90
        Self::InvalidParameters
×
91
    }
×
92
}
93

94
impl embedded_nal::TcpError for StackError {
95
    fn kind(&self) -> embedded_nal::TcpErrorKind {
×
96
        if matches!(self, StackError::OpFailed(SocketError::ConnAborted)) {
×
97
            embedded_nal::TcpErrorKind::PipeClosed
×
98
        } else {
99
            embedded_nal::TcpErrorKind::Other
×
100
        }
101
    }
×
102
}
103

104
impl From<nb::Error<StackError>> for StackError {
105
    fn from(inner: nb::Error<StackError>) -> Self {
×
106
        match inner {
×
107
            nb::Error::WouldBlock => StackError::WouldBlock,
×
108
            nb::Error::Other(e) => e,
×
109
        }
110
    }
×
111
}
112

113
impl core::fmt::Display for StackError {
114
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
×
115
        match self {
×
116
            Self::WouldBlock => write!(f, "Operation would block"),
×
117
            Self::GeneralTimeout => write!(f, "General timeout"),
×
118
            Self::ConnectTimeout => write!(f, "TCP connection timed out"),
×
119
            Self::RecvTimeout => write!(f, "Receive timeout"),
×
120
            Self::SendTimeout => write!(f, "Send timeout"),
×
121
            Self::OutOfSockets => write!(f, "Out of sockets"),
×
122
            Self::SocketAlreadyInUse => write!(f, "Socket already in use"),
×
123
            Self::CloseFailed => write!(f, "Close failed"),
×
124
            Self::Unexpected => write!(f, "Unexpected error"),
×
125
            Self::DispatchError(err) => write!(f, "Dispatch error: {}", err),
×
126
            Self::ConnectSendFailed(err) => write!(f, "Connect send failed: {}", err),
×
127
            Self::ReceiveFailed(err) => write!(f, "Receive failed: {}", err),
×
128
            Self::SendSendFailed(err) => write!(f, "Send send failed: {}", err),
×
129
            Self::SendCloseFailed(err) => write!(f, "Send close failed: {}", err),
×
130
            Self::BindFailed(err) => write!(f, "Bind failed: {}", err),
×
131
            Self::WincWifiFail(err) => write!(f, "WincWifi fail: {}", err),
×
132
            Self::OpFailed(err) => write!(f, "Operation failed: {}", err),
×
133
            Self::DnsTimeout => write!(f, "DNS lookup timed out"),
×
134
            Self::DnsFailed => write!(f, "DNS lookup failed"),
×
135
            Self::InvalidState => write!(f, "Invalid state"),
×
136
            Self::AlreadyConnected => write!(f, "Already connected"),
×
137
            Self::ApJoinFailed(err) => write!(f, "Access point join failed: {}", err),
×
138
            Self::ApScanFailed(err) => write!(f, "Access point scan failed: {}", err),
×
139
            Self::ContinueOperation => write!(f, "Continue operation"),
×
140
            Self::SocketNotFound => write!(f, "Socket not found"),
×
141
            Self::InvalidParameters => write!(f, "Invalid parameters"),
×
142
            Self::InvalidResponse => write!(f, "Invalid response"),
×
143
            #[cfg(feature = "experimental-ota")]
144
            Self::OtaFail(err) => write!(f, "Ota failure: {:?}", err),
145
            #[cfg(feature = "async")]
146
            Self::TooManyWakers => write!(f, "Too many concurrent async operations"),
×
147
            #[cfg(feature = "async")]
NEW
148
            Self::ResourceBusy => write!(f, "Resources busy"),
×
149
        }
150
    }
×
151
}
152

153
#[cfg(feature = "async")]
154
impl embedded_io_async::Error for StackError {
155
    fn kind(&self) -> embedded_io_async::ErrorKind {
×
156
        embedded_io_async::ErrorKind::Other
×
157
    }
×
158
}
159

160
#[cfg(feature = "async")]
161
impl core::error::Error for StackError {}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc