Skip to main content

ferrite_session/internal/protocol/
end.rs

1use core::{
2  future::Future,
3  pin::Pin,
4};
5
6use crate::internal::base::*;
7
8pub struct End;
9
10impl SealedProtocol for End {}
11
12impl Protocol for End
13{
14  type ClientEndpoint = ReceiverOnce<()>;
15  type ProviderEndpoint = SenderOnce<()>;
16
17  fn create_endpoints() -> (Self::ProviderEndpoint, Self::ClientEndpoint)
18  {
19    once_channel()
20  }
21
22  fn forward(
23    client_end: Self::ClientEndpoint,
24    provider_end: Self::ProviderEndpoint,
25  ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
26  {
27    Box::pin(async {
28      let payload = client_end.recv().await.unwrap();
29      provider_end.send(payload).unwrap();
30    })
31  }
32}
33
34impl<A> RecApp<A> for End
35{
36  type Applied = End;
37}