Trait tor_async_utils::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.

Object Safety§

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§