pub trait ClientLayer<In, Out>:
Send
+ Sync
+ Clone {
// Required method
fn handshake(&self, input: In) -> impl Future<Output = Result<Out>> + Send;
}Expand description
Client-side middleware layer. Upgrades an input via handshake.
Generic over input and output types:
ClientLayer<Box<dyn ByteStream>, Box<dyn ByteStream>>- TLS, SOCKS5, NoiseClientLayer<Box<dyn ByteStream>, WsConn<C>>- WebSocket
§Example
use karyon_net::{tcp, tls, ClientLayer, ByteStream, Endpoint};
use karyon_net::tls::ClientTlsConfig;
async {
let ep: Endpoint = "tcp://127.0.0.1:443".parse().unwrap();
let stream = tcp::connect(&ep, Default::default()).await.unwrap();
// let tls_stream: Box<dyn ByteStream> = ClientLayer::handshake(
// &tls::TlsLayer::client(config), stream
// ).await.unwrap();
};Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.