pub trait GenericSend<T>where
T: Serialize + for<'de> Deserialize<'de>,{
// Required methods
fn send(&self, _: T) -> SendResult;
fn sender(&self) -> GenericSender<T>;
// Provided methods
fn send_or_warn(&self, message: T) { ... }
fn send_or_ignore(&self, message: T) { ... }
}Expand description
Abstraction of the ability to send a particular type of message cross-process. This can be used to ease the use of GenericSender sub-fields.
Required Methods§
Sourcefn send(&self, _: T) -> SendResult
fn send(&self, _: T) -> SendResult
send message T
Sourcefn sender(&self) -> GenericSender<T>
fn sender(&self) -> GenericSender<T>
get underlying sender
Provided Methods§
Sourcefn send_or_warn(&self, message: T)
fn send_or_warn(&self, message: T)
Send a message T and log any error (instead of returning it).
In cases where channel closure is possible (because the receiver does not exist anymore), this convenience method can be used to ignore the result and log the error as a warning.
Sourcefn send_or_ignore(&self, message: T)
fn send_or_ignore(&self, message: T)
Send a message T and ignore the result
In cases where channel closure is expected to happen intermittently, and the sender
doesn’t care about the result, this is a short form for let _ = GenericSend::send();,
which makes the intent clearer.