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

kaidokert / winc-rs / 15917868527

27 Jun 2025 04:02AM UTC coverage: 83.613% (-1.3%) from 84.889%
15917868527

Pull #90

github

kaidokert
Cleanups
Pull Request #90: Cleaner api

11 of 19 new or added lines in 7 files covered. (57.89%)

25 existing lines in 2 files now uncovered.

3837 of 4589 relevant lines covered (83.61%)

41697.16 hits per line

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

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

3
use crate::manager::SocketError;
4

5
use embedded_nal::nb;
6

7
/// Stack errors
8
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9
#[derive(Debug, PartialEq)]
10
pub enum StackError {
11
    WouldBlock,
12
    GeneralTimeout,
13
    /// TCP connection timed out
14
    ConnectTimeout,
15
    RecvTimeout,
16
    SendTimeout,
17
    OutOfSockets,
18
    SocketAlreadyInUse,
19
    CloseFailed,
20
    Unexpected,
21
    DispatchError(crate::errors::CommError),
22
    ConnectSendFailed(crate::errors::CommError),
23
    ReceiveFailed(crate::errors::CommError),
24
    SendSendFailed(crate::errors::CommError),
25
    SendCloseFailed(crate::errors::CommError),
26
    BindFailed(crate::errors::CommError),
27
    WincWifiFail(crate::errors::CommError),
28
    OpFailed(SocketError),
29
    /// DNS lookup timed out
30
    DnsTimeout,
31
    /// Unexpected DNS error
32
    DnsFailed,
33
    /// Operation was attempted in wrong state
34
    InvalidState,
35
    AlreadyConnected,
36
    /// Acess point join failed
37
    ApJoinFailed(WifiConnError),
38
    /// Scan operation failed
39
    ApScanFailed(WifiConnError),
40
    // Continue
41
    ContinueOperation,
42
    /// Not found
43
    SocketNotFound,
44
    /// Parameters are not valid.
45
    InvalidParameters,
46
}
47

48
impl From<core::convert::Infallible> for StackError {
49
    fn from(_: core::convert::Infallible) -> Self {
×
50
        unreachable!()
×
51
    }
52
}
53

54
impl From<SocketError> for StackError {
55
    fn from(inner: SocketError) -> Self {
×
56
        Self::OpFailed(inner)
×
57
    }
×
58
}
59

60
impl From<crate::errors::CommError> for StackError {
NEW
61
    fn from(inner: crate::errors::CommError) -> Self {
×
62
        Self::WincWifiFail(inner)
×
63
    }
×
64
}
65

66
impl embedded_nal::TcpError for StackError {
67
    fn kind(&self) -> embedded_nal::TcpErrorKind {
×
68
        embedded_nal::TcpErrorKind::Other
×
69
    }
×
70
}
71

72
impl From<nb::Error<StackError>> for StackError {
73
    fn from(inner: nb::Error<StackError>) -> Self {
×
74
        match inner {
×
75
            nb::Error::WouldBlock => StackError::WouldBlock,
×
76
            nb::Error::Other(e) => e,
×
77
        }
78
    }
×
79
}
80

81
impl core::fmt::Display for StackError {
82
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
×
83
        match self {
×
84
            Self::WouldBlock => write!(f, "Operation would block"),
×
85
            Self::GeneralTimeout => write!(f, "General timeout"),
×
86
            Self::ConnectTimeout => write!(f, "TCP connection timed out"),
×
87
            Self::RecvTimeout => write!(f, "Receive timeout"),
×
88
            Self::SendTimeout => write!(f, "Send timeout"),
×
89
            Self::OutOfSockets => write!(f, "Out of sockets"),
×
90
            Self::SocketAlreadyInUse => write!(f, "Socket already in use"),
×
91
            Self::CloseFailed => write!(f, "Close failed"),
×
92
            Self::Unexpected => write!(f, "Unexpected error"),
×
93
            Self::DispatchError(err) => write!(f, "Dispatch error: {}", err),
×
94
            Self::ConnectSendFailed(err) => write!(f, "Connect send failed: {}", err),
×
95
            Self::ReceiveFailed(err) => write!(f, "Receive failed: {}", err),
×
96
            Self::SendSendFailed(err) => write!(f, "Send send failed: {}", err),
×
97
            Self::SendCloseFailed(err) => write!(f, "Send close failed: {}", err),
×
98
            Self::BindFailed(err) => write!(f, "Bind failed: {}", err),
×
99
            Self::WincWifiFail(err) => write!(f, "WincWifi fail: {}", err),
×
100
            Self::OpFailed(err) => write!(f, "Operation failed: {}", err),
×
101
            Self::DnsTimeout => write!(f, "DNS lookup timed out"),
×
102
            Self::DnsFailed => write!(f, "DNS lookup failed"),
×
103
            Self::InvalidState => write!(f, "Invalid state"),
×
104
            Self::AlreadyConnected => write!(f, "Already connected"),
×
105
            Self::ApJoinFailed(err) => write!(f, "Access point join failed: {}", err),
×
106
            Self::ApScanFailed(err) => write!(f, "Access point scan failed: {}", err),
×
107
            Self::ContinueOperation => write!(f, "Continue operation"),
×
108
            Self::SocketNotFound => write!(f, "Socket not found"),
×
109
            Self::InvalidParameters => write!(f, "Invalid parameters"),
×
110
        }
111
    }
×
112
}
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