Skip to content

Commit

Permalink
examples: updated TokioIo dependencies using hyper_util
Browse files Browse the repository at this point in the history
  • Loading branch information
sheroz committed Nov 17, 2023
1 parent e3be311 commit 985a243
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 45 deletions.
4 changes: 1 addition & 3 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use hyper::Request;
use tokio::io::{self, AsyncWriteExt as _};
use tokio::net::TcpStream;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// A simple type alias so as to DRY.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down
4 changes: 1 addition & 3 deletions examples/client_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use hyper::{body::Buf, Request};
use serde::Deserialize;
use tokio::net::TcpStream;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// A simple type alias so as to DRY.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down
4 changes: 1 addition & 3 deletions examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use hyper::service::service_fn;
use hyper::{body::Body, Method, Request, Response, StatusCode};
use tokio::net::TcpListener;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

/// This is our service handler. It receives a Request, routes on its
/// path, and returns a Future of a Response.
Expand Down
4 changes: 1 addition & 3 deletions examples/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use hyper::{server::conn::http1, service::service_fn};
use std::net::SocketAddr;
use tokio::net::{TcpListener, TcpStream};

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
4 changes: 1 addition & 3 deletions examples/graceful_shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use hyper::{Request, Response};
use tokio::net::TcpListener;
use tokio::pin;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// An async function that consumes a request, does nothing with it and returns a
// response.
Expand Down
4 changes: 1 addition & 3 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use hyper::service::service_fn;
use hyper::{Request, Response};
use tokio::net::TcpListener;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// An async function that consumes a request, does nothing with it and returns a
// response.
Expand Down
4 changes: 1 addition & 3 deletions examples/http_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use hyper::{Method, Request, Response};

use tokio::net::{TcpListener, TcpStream};

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// To try this example:
// 1. cargo run --example http_proxy
Expand Down
4 changes: 1 addition & 3 deletions examples/multi_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use hyper::service::service_fn;
use hyper::{Request, Response};
use tokio::net::TcpListener;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

static INDEX1: &[u8] = b"The 1st service!";
static INDEX2: &[u8] = b"The 2nd service!";
Expand Down
4 changes: 1 addition & 3 deletions examples/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use std::collections::HashMap;
use std::convert::Infallible;
use std::net::SocketAddr;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

static INDEX: &[u8] = b"<html><body><form action=\"post\" method=\"post\">Name: <input type=\"text\" name=\"name\"><br>Number: <input type=\"text\" name=\"number\"><br><input type=\"submit\"></body></html>";
static MISSING: &[u8] = b"Missing field";
Expand Down
4 changes: 1 addition & 3 deletions examples/send_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use http_body_util::Full;
use hyper::service::service_fn;
use hyper::{Method, Request, Response, Result, StatusCode};

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

static INDEX: &str = "examples/send_file_index.html";
static NOTFOUND: &[u8] = b"Not Found";
Expand Down
4 changes: 1 addition & 3 deletions examples/service_struct_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use std::net::SocketAddr;
use std::pin::Pin;
use std::sync::Mutex;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

type Counter = i32;

Expand Down
4 changes: 1 addition & 3 deletions examples/single_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ use std::task::{Context, Poll};
use std::thread;
use tokio::net::TcpStream;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

struct Body {
// Our Body type is !Send and !Sync:
Expand Down
4 changes: 1 addition & 3 deletions examples/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use hyper::{server::conn::http1, service::service_fn};
use hyper::{Error, Response};
use tokio::net::TcpListener;

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
4 changes: 1 addition & 3 deletions examples/upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ use hyper::service::service_fn;
use hyper::upgrade::Upgraded;
use hyper::{Request, Response, StatusCode};

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

// A simple type alias so as to DRY.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down
4 changes: 1 addition & 3 deletions examples/web_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use hyper::service::service_fn;
use hyper::{body::Incoming as IncomingBody, header, Method, Request, Response, StatusCode};
use tokio::net::{TcpListener, TcpStream};

#[path = "../benches/support/mod.rs"]
mod support;
use support::TokioIo;
use hyper_util::rt::TokioIo;

type GenericError = Box<dyn std::error::Error + Send + Sync>;
type Result<T> = std::result::Result<T, GenericError>;
Expand Down

0 comments on commit 985a243

Please sign in to comment.