diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-02-20 11:53:55 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-02-24 12:45:07 +0000 |
| commit | 76cd4dca9c5822458fbe94407d16c816ec6bd6a9 (patch) | |
| tree | ae6f1749266a09775b96c1f550d30e019f27656c /talpid-core/src | |
| parent | efafe534031485832f0dda5caa7c98069c2e3b15 (diff) | |
| download | mullvadvpn-76cd4dca9c5822458fbe94407d16c816ec6bd6a9.tar.xz mullvadvpn-76cd4dca9c5822458fbe94407d16c816ec6bd6a9.zip | |
Create `Sender` trait
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/mpsc.rs | 6 |
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> { |
