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

kaidokert / winc-rs / 21784680303

07 Feb 2026 06:17PM UTC coverage: 83.145% (-1.2%) from 84.301%
21784680303

Pull #129

github

web-flow
Merge 4593a3299 into ca90ae80c
Pull Request #129: Replace magic numbers with constants.

116 of 163 new or added lines in 8 files covered. (71.17%)

179 existing lines in 9 files now uncovered.

4647 of 5589 relevant lines covered (83.15%)

34561.65 hits per line

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

10.34
/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
}
60

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

67
impl From<SocketError> for StackError {
UNCOV
68
    fn from(inner: SocketError) -> Self {
×
UNCOV
69
        Self::OpFailed(inner)
×
UNCOV
70
    }
×
71
}
72

73
impl From<crate::errors::CommError> for StackError {
74
    fn from(inner: crate::errors::CommError) -> Self {
1✔
75
        Self::WincWifiFail(inner)
1✔
76
    }
1✔
77
}
78

79
impl From<crate::errors::CommError> for nb::Error<StackError> {
80
    fn from(inner: crate::errors::CommError) -> Self {
1✔
81
        nb::Error::Other(StackError::WincWifiFail(inner))
1✔
82
    }
1✔
83
}
84

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

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

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

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

148
#[cfg(feature = "async")]
149
impl embedded_io_async::Error for StackError {
UNCOV
150
    fn kind(&self) -> embedded_io_async::ErrorKind {
×
UNCOV
151
        embedded_io_async::ErrorKind::Other
×
UNCOV
152
    }
×
153
}
154

155
#[cfg(feature = "async")]
156
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