pub trait MessageBusExtensions {
// Required method
fn as_message_bus(&self) -> Rc<dyn IMessageBus>;
// Provided methods
fn with_message_bus(&self) -> Rc<dyn IDisposable> { ... }
fn with<R>(&self, block: impl FnOnce() -> R) -> R { ... }
}Expand description
Runs code with a message bus as MessageBus::current (MessageBusExtensions).
Deviation (DEVIATIONS.md, ReactiveUI): the current message bus is per thread, so upstream’s
lock (Monitor.Enter(messageBusGate)), which keeps the tests of other threads from replacing
it in between, is not needed and not ported.
Required Methods§
Sourcefn as_message_bus(&self) -> Rc<dyn IMessageBus>
fn as_message_bus(&self) -> Rc<dyn IMessageBus>
The message bus as the handle that MessageBus::current holds.
Provided Methods§
Sourcefn with_message_bus(&self) -> Rc<dyn IDisposable>
fn with_message_bus(&self) -> Rc<dyn IDisposable>
Makes the message bus MessageBus::current until the returned disposable is disposed,
which restores the message bus that was current before (WithMessageBus).
Sourcefn with<R>(&self, block: impl FnOnce() -> R) -> R
fn with<R>(&self, block: impl FnOnce() -> R) -> R
Runs block with the message bus as MessageBus::current and returns its result; the
message bus current before is restored afterwards, also when block panics
(With<TRet>(Func<TRet>), and With(Action) with a block that returns ()).
Not ported: the ArgumentException of a null block - argument validation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".