diff --git a/examples/h2_client.rs b/examples/h2_client.rs index aab048a4..d8203d18 100644 --- a/examples/h2_client.rs +++ b/examples/h2_client.rs @@ -1,15 +1,16 @@ //! Example for using h2 directly. -//! Note: This is only meant for compatible usage. //! Example code is modified from https://github.com/hyperium/h2/blob/master/examples/client.rs. -use monoio::net::TcpStream; -use monoio_compat::StreamWrapper; +use monoio::{io::IntoPollIo, net::TcpStream}; #[monoio::main] async fn main() { - let tcp = TcpStream::connect("127.0.0.1:5928").await.unwrap(); - let tcp_wrapper = StreamWrapper::new(tcp); - let (mut client, h2) = h2::client::handshake(tcp_wrapper).await.unwrap(); + let io = TcpStream::connect("127.0.0.1:5928") + .await + .unwrap() + .into_poll_io() + .unwrap(); + let (mut client, h2) = h2::client::handshake(io).await.unwrap(); println!("sending request"); diff --git a/examples/h2_server.rs b/examples/h2_server.rs index 60e0c97f..d44134b6 100644 --- a/examples/h2_server.rs +++ b/examples/h2_server.rs @@ -1,13 +1,14 @@ //! Example for using h2 directly. -//! Note: This is only meant for compatible usage. //! Example code is modified from https://github.com/hyperium/h2/blob/master/examples/server.rs. -use monoio::net::{TcpListener, TcpStream}; -use monoio_compat::StreamWrapper; +use monoio::{ + io::IntoPollIo, + net::{TcpListener, TcpStream}, +}; -async fn serve(socket: TcpStream) -> Result<(), Box> { - let socket_wrapper = StreamWrapper::new(socket); - let mut connection = h2::server::handshake(socket_wrapper).await?; +async fn serve(io: TcpStream) -> Result<(), Box> { + let io = io.into_poll_io()?; + let mut connection = h2::server::handshake(io).await?; println!("H2 connection bound"); while let Some(result) = connection.accept().await {