Skip to main content

volans_core/
upgrade.rs

1mod apply;
2mod denied;
3mod either;
4mod error;
5mod pending;
6mod ready;
7mod select;
8
9pub use apply::{InboundUpgradeApply, OutboundUpgradeApply, apply};
10pub use denied::DeniedUpgrade;
11pub use error::UpgradeError;
12pub use pending::PendingUpgrade;
13pub use ready::ReadyUpgrade;
14pub use select::SelectUpgrade;
15
16/// 升级信息
17pub trait UpgradeInfo {
18    type Info: AsRef<str> + Clone;
19    type InfoIter: Iterator<Item = Self::Info>;
20
21    fn protocol_info(&self) -> Self::InfoIter;
22}
23
24pub trait InboundUpgrade<C>: UpgradeInfo {
25    type Output;
26    type Error;
27    type Future: Future<Output = Result<Self::Output, Self::Error>>;
28
29    /// 升级入站流
30    fn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future;
31}
32
33pub trait OutboundUpgrade<C>: UpgradeInfo {
34    type Output;
35    type Error;
36    type Future: Future<Output = Result<Self::Output, Self::Error>>;
37
38    /// 升级出站流
39    fn upgrade_outbound(self, socket: C, info: Self::Info) -> Self::Future;
40}
41
42pub trait InboundConnectionUpgrade<C>: UpgradeInfo {
43    type Output;
44    type Error;
45    type Future: Future<Output = Result<Self::Output, Self::Error>>;
46
47    fn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future;
48}
49
50pub trait OutboundConnectionUpgrade<C>: UpgradeInfo {
51    type Output;
52    type Error;
53    type Future: Future<Output = Result<Self::Output, Self::Error>>;
54
55    fn upgrade_outbound(self, socket: C, info: Self::Info) -> Self::Future;
56}