summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-02-20 11:53:55 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-02-24 12:45:07 +0000
commit76cd4dca9c5822458fbe94407d16c816ec6bd6a9 (patch)
treeae6f1749266a09775b96c1f550d30e019f27656c
parentefafe534031485832f0dda5caa7c98069c2e3b15 (diff)
downloadmullvadvpn-76cd4dca9c5822458fbe94407d16c816ec6bd6a9.tar.xz
mullvadvpn-76cd4dca9c5822458fbe94407d16c816ec6bd6a9.zip
Create `Sender` trait
-rw-r--r--talpid-core/src/mpsc.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/talpid-core/src/mpsc.rs b/talpid-core/src/mpsc.rs
index 21807ca377..8ac152a082 100644
--- a/talpid-core/src/mpsc.rs
+++ b/talpid-core/src/mpsc.rs
@@ -1,6 +1,12 @@
use futures::sync::mpsc::{SendError, UnboundedSender};
use std::marker::PhantomData;
+/// Abstraction over any type that can be used similarly to an `std::mpsc::Sender`.
+pub trait Sender<T> {
+ /// Sends an item over the underlying channel, failing only if the channel is closed.
+ fn send(&self, item: T) -> Result<(), ()>;
+}
+
/// Abstraction over an `mpsc::Sender` that first converts the value to another type before sending.
#[derive(Debug, Clone)]
pub struct IntoSender<T, U> {