hermes_async_runtime_components/stream/impls/
boxed.rs

1use alloc::boxed::Box;
2use core::pin::Pin;
3
4use cgp::prelude::*;
5use futures_core::stream::Stream;
6use hermes_runtime_components::traits::stream::ProvideStreamType;
7
8use crate::stream::traits::boxed::BoxedStreamTypeProvider;
9
10pub struct ProvideBoxedStreamType;
11
12impl<Runtime> ProvideStreamType<Runtime> for ProvideBoxedStreamType
13where
14    Runtime: Async,
15{
16    type Stream<Item: Async> = Pin<Box<dyn Stream<Item = Item> + Send + Sync + 'static>>;
17}
18
19impl<Runtime> BoxedStreamTypeProvider<Runtime> for ProvideBoxedStreamType
20where
21    Runtime: Async,
22{
23    fn to_boxed_stream<Item>(
24        stream: Self::Stream<Item>,
25    ) -> Pin<Box<dyn Stream<Item = Item> + Send + Sync + 'static>>
26    where
27        Item: Async,
28    {
29        stream
30    }
31
32    fn from_boxed_stream<Item>(
33        stream: Pin<Box<dyn Stream<Item = Item> + Send + Sync + 'static>>,
34    ) -> Self::Stream<Item>
35    where
36        Item: Async,
37    {
38        stream
39    }
40}