Skip to content

Commit

Permalink
feat: add fmt:display + std::error::Error to RecvError
Browse files Browse the repository at this point in the history
- also closes #59
  • Loading branch information
john-bv committed Feb 3, 2024
1 parent db79e7b commit a1b3533
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,23 @@ use tokio::{
time::sleep,
};
#[cfg(feature = "async_tokio")]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum RecvError {
Closed,
Timeout,
}
#[cfg(feature = "async_tokio")]
impl std::fmt::Display for RecvError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RecvError::Closed => write!(f, "RecvError: Channel is closed!"),
RecvError::Timeout => write!(f, "RecvError: Timeout!"),
}
}
}

#[cfg(feature = "async_tokio")]
impl std::error::Error for RecvError {}

use crate::{
notify::Notify,
Expand Down

0 comments on commit a1b3533

Please sign in to comment.