quic_rpc/transport/misc/
mod.rs1use std::convert::Infallible;
3
4use futures_lite::stream;
5use futures_sink::Sink;
6
7use super::StreamTypes;
8use crate::{
9 transport::{ConnectionErrors, Listener},
10 RpcMessage,
11};
12
13#[derive(Debug, Default)]
18pub struct DummyListener<In, Out> {
19 _p: std::marker::PhantomData<(In, Out)>,
20}
21
22impl<In, Out> Clone for DummyListener<In, Out> {
23 fn clone(&self) -> Self {
24 Self {
25 _p: std::marker::PhantomData,
26 }
27 }
28}
29
30impl<In: RpcMessage, Out: RpcMessage> ConnectionErrors for DummyListener<In, Out> {
31 type RecvError = Infallible;
32 type SendError = Infallible;
33 type OpenError = Infallible;
34 type AcceptError = Infallible;
35}
36
37impl<In: RpcMessage, Out: RpcMessage> StreamTypes for DummyListener<In, Out> {
38 type In = In;
39 type Out = Out;
40 type RecvStream = stream::Pending<Result<In, Self::RecvError>>;
41 type SendSink = Box<dyn Sink<Out, Error = Self::SendError> + Unpin + Send + Sync>;
42}
43
44impl<In: RpcMessage, Out: RpcMessage> Listener for DummyListener<In, Out> {
45 async fn accept(&self) -> Result<(Self::SendSink, Self::RecvStream), Self::AcceptError> {
46 futures_lite::future::pending().await
47 }
48
49 fn local_addr(&self) -> &[super::LocalAddr] {
50 &[]
51 }
52}