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§
sourcefn try_maybe_send<F, E>(&mut self, update: F) -> Result<(), E>
fn try_maybe_send<F, E>(&mut self, update: F) -> Result<(), 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§
sourcefn maybe_send<F>(&mut self, update: F)
fn maybe_send<F>(&mut self, update: F)
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.