async_proxy/
proxy.rs

1/// A general trait that represents
2/// something that constructs a proxy stream,
3/// something, where we can write to and read from
4/// just as from a usual stream but through a proxy
5#[async_trait::async_trait]
6pub trait ProxyConstructor {
7    /// Represents a stream that the proxy
8    /// client operates on (sends protocol data over it)
9    type Stream: Send;
10    /// Represents the actual proxy stream,
11    /// returned by the connect function
12    type ProxyStream: Send;
13    /// Used for internal proxy error indication
14    type ErrorKind;
15
16    /// Takes ownership of an existant stream,
17    /// establishes a proxixied connection on the stream
18    /// and returns the proxy stream if the connection was
19    /// successful, unless an error
20    async fn connect(&mut self, stream: Self::Stream)
21        -> Result<Self::ProxyStream, Self::ErrorKind>
22    where
23        Self: Sized;
24}