Trait CanCreateClosureSubscription

Source
pub trait CanCreateClosureSubscription {
    // Required method
    fn new_closure_subscription<T: Async>(
        subscribe: impl Fn() -> Pin<Box<dyn Future<Output = Option<Pin<Box<dyn Stream<Item = T> + Send + Sync + 'static>>>> + Send + 'static>> + Send + Sync + 'static,
    ) -> Arc<dyn Subscription<Item = T>>;
}
Expand description

An auto trait that is implemented by all runtime contexts that implement HasMutex. This allows simple creation of Subscription values by wrapping an async closure that returns the same thing as subscribe.

The returned Subscription also implements guard to skip calling the underlying closure once the closure returns None.

Required Methods§

Source

fn new_closure_subscription<T: Async>( subscribe: impl Fn() -> Pin<Box<dyn Future<Output = Option<Pin<Box<dyn Stream<Item = T> + Send + Sync + 'static>>>> + Send + 'static>> + Send + Sync + 'static, ) -> Arc<dyn Subscription<Item = T>>

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.

Implementors§

Source§

impl<Runtime> CanCreateClosureSubscription for Runtime
where Runtime: HasMutex,