xwt_core/endpoint/
accept.rs

1#![allow(missing_docs)]
2
3use core::future::Future;
4
5use crate::utils::{maybe, Error};
6
7pub trait Accept: maybe::Send {
8    type Accepting: Accepting;
9    type Error: Error + maybe::Send + maybe::Sync + 'static;
10
11    fn accept(
12        &self,
13    ) -> impl Future<Output = Result<Option<Self::Accepting>, Self::Error>> + maybe::Send;
14}
15
16pub trait Accepting: maybe::Send {
17    type Request: Request;
18    type Error: Error + maybe::Send + maybe::Sync + 'static;
19
20    fn wait_accept(self) -> impl Future<Output = Result<Self::Request, Self::Error>> + maybe::Send;
21}
22
23pub trait Request: maybe::Send {
24    type Session: maybe::Send;
25    type OkError: Error + maybe::Send + maybe::Sync + 'static;
26    type CloseError: Error + maybe::Send + maybe::Sync + 'static;
27
28    fn ok(self) -> impl Future<Output = Result<Self::Session, Self::OkError>> + maybe::Send;
29
30    fn close(self, status: u16)
31        -> impl Future<Output = Result<(), Self::CloseError>> + maybe::Send;
32}