Trait PostageWatchSenderExt

Source
pub trait PostageWatchSenderExt<T> {
    // Required method
    fn try_maybe_send<F, E>(&mut self, update: F) -> Result<(), E>
       where T: PartialEq,
             F: FnOnce(&T) -> Result<T, E>;

    // Provided method
    fn maybe_send<F>(&mut self, update: F)
       where T: PartialEq,
             F: FnOnce(&T) -> T { ... }
}
Expand description

Extension trait for some postage::watch::Sender to provide maybe_send

Ideally these, or something like them, would be upstream: See https://github.com/austinjones/postage-rs/issues/56.

We provide this as an extension trait became the implementation is a bit fiddly. This lets us concentrate on the actual logic, when we use it.

Required Methods§

Source

fn try_maybe_send<F, E>(&mut self, update: F) -> Result<(), E>
where T: PartialEq, F: FnOnce(&T) -> Result<T, E>,

Update, by calling a fallible function, sending only if necessary

Calls update on the current value in the watch, to obtain a new value. If the new value doesn’t compare equal, updates the watch, notifying receivers.

Provided Methods§

Source

fn maybe_send<F>(&mut self, update: F)
where T: PartialEq, F: FnOnce(&T) -> T,

Update, by calling a function, sending only if necessary

Calls update on the current value in the watch, to obtain a new value. If the new value doesn’t compare equal, updates the watch, notifying receivers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> PostageWatchSenderExt<T> for Sender<T>

Source§

fn try_maybe_send<F, E>(&mut self, update: F) -> Result<(), E>
where T: PartialEq, F: FnOnce(&T) -> Result<T, E>,

Implementors§