summaryrefslogtreecommitdiffstats
path: root/tokio-sync/src/oneshot.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio-sync/src/oneshot.rs')
-rw-r--r--tokio-sync/src/oneshot.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tokio-sync/src/oneshot.rs b/tokio-sync/src/oneshot.rs
index f8e82567..bb11d4e6 100644
--- a/tokio-sync/src/oneshot.rs
+++ b/tokio-sync/src/oneshot.rs
@@ -32,6 +32,8 @@ pub struct Receiver<T> {
pub mod error {
//! Oneshot error types
+ use std::fmt;
+
/// Error returned by the `Future` implementation for `Receiver`.
#[derive(Debug)]
pub struct RecvError(pub(super) ());
@@ -39,6 +41,36 @@ pub mod error {
/// Error returned by the `try_recv` function on `Receiver`.
#[derive(Debug)]
pub struct TryRecvError(pub(super) ());
+
+ // ===== impl RecvError =====
+
+ impl fmt::Display for RecvError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ use std::error::Error;
+ write!(fmt, "{}", self.description())
+ }
+ }
+
+ impl ::std::error::Error for RecvError {
+ fn description(&self) -> &str {
+ "channel closed"
+ }
+ }
+
+ // ===== impl TryRecvError =====
+
+ impl fmt::Display for TryRecvError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ use std::error::Error;
+ write!(fmt, "{}", self.description())
+ }
+ }
+
+ impl ::std::error::Error for TryRecvError {
+ fn description(&self) -> &str {
+ "channel closed"
+ }
+ }
}
use self::error::*;