Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented std::error::Error for ReachabilityError. #60

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Line wrap the file at 100 chars. Th

## [Unreleased]

### Added
- Added `std::error::Error` implementation for `ReachabilityError`.

## [0.6.1] - 2024-08-22
### Fixed
- Fix `std::net::SocketAddr` conversion to `libc::sockaddr`. This makes `SCNetworkReachability`
Expand Down
13 changes: 13 additions & 0 deletions system-configuration/src/network_reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ pub enum ReachabilityError {
UnrecognizedFlags(u32),
}

impl Display for ReachabilityError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::FailedToDetermineReachability => write!(f, "Failed to determine reachability"),
Self::UnrecognizedFlags(flags) => {
write!(f, "Unrecognized reachability flags: {}", flags)
}
}
}
}

impl Error for ReachabilityError {}

/// Failure to schedule a reachability callback on a runloop.
#[derive(Debug)]
pub struct SchedulingError(());
Expand Down
Loading