hermes_runtime_components/traits/
channel_once.rs1use cgp::prelude::*;
2
3#[derive_component(ChannelOnceTypeComponent, ProvideChannelOnceType<Runtime>)]
4pub trait HasChannelOnceTypes {
5 type SenderOnce<T>: Async
6 where
7 T: Async;
8
9 type ReceiverOnce<T>: Async
10 where
11 T: Async;
12}
13
14pub type SenderOnceOf<Runtime, T> = <Runtime as HasChannelOnceTypes>::SenderOnce<T>;
15
16pub type ReceiverOnce<Runtime, T> = <Runtime as HasChannelOnceTypes>::ReceiverOnce<T>;
17
18#[derive_component(ChannelOnceCreatorComponent, ChannelOnceCreator<Runtime>)]
19pub trait CanCreateChannelsOnce: HasChannelOnceTypes {
20 fn new_channel_once<T>() -> (Self::SenderOnce<T>, Self::ReceiverOnce<T>)
21 where
22 T: Async;
23}
24
25#[derive_component(ChannelOnceUserComponent, ChannelOnceUser<Runtime>)]
26#[async_trait]
27pub trait CanUseChannelsOnce: HasChannelOnceTypes + HasErrorType {
28 fn send_once<T>(sender: Self::SenderOnce<T>, value: T) -> Result<(), Self::Error>
29 where
30 T: Async;
31
32 async fn receive_once<T>(receiver: Self::ReceiverOnce<T>) -> Result<T, Self::Error>
33 where
34 T: Async;
35}