hermes_async_runtime_components/subscription/impls/
empty.rs

1use alloc::boxed::Box;
2use core::marker::PhantomData;
3use core::pin::Pin;
4
5use cgp::prelude::*;
6use futures_core::stream::Stream;
7
8use crate::subscription::traits::subscription::Subscription;
9
10pub struct EmptySubscription<T>(pub PhantomData<T>);
11
12impl<T> Default for EmptySubscription<T> {
13    fn default() -> Self {
14        Self(PhantomData)
15    }
16}
17
18impl<T> EmptySubscription<T> {
19    pub fn new() -> Self {
20        Self(PhantomData)
21    }
22}
23
24#[async_trait::async_trait]
25impl<T: Async> Subscription for EmptySubscription<T> {
26    type Item = T;
27
28    async fn subscribe(
29        &self,
30    ) -> Option<Pin<Box<dyn Stream<Item = Self::Item> + Send + Sync + 'static>>> {
31        None
32    }
33}