trillium_server_common/
acceptor.rs1use crate::Transport;
2use std::{convert::Infallible, fmt::Debug, future::Future};
3
4pub trait Acceptor<Input>: Clone + Send + Sync + 'static
10where
11 Input: Transport,
12{
13 type Output: Transport;
15
16 type Error: Debug + Send + Sync;
18
19 fn accept(
22 &self,
23 input: Input,
24 ) -> impl Future<Output = Result<Self::Output, Self::Error>> + Send;
25
26 fn is_secure(&self) -> bool {
28 true
29 }
30}
31
32impl<Input> Acceptor<Input> for ()
33where
34 Input: Transport,
35{
36 type Error = Infallible;
37 type Output = Input;
38
39 async fn accept(&self, input: Input) -> Result<Self::Output, Self::Error> {
40 Ok(input)
41 }
42
43 fn is_secure(&self) -> bool {
44 false
45 }
46}