-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move utilities and combinators to a separate package
Hyper works with all combinators removed. Removing methods from the trait is a breaking change, but it is possible to do the semver trick (release 0.5, then release 0.4.x with a dependency on the 0.5 trait) to not split the ecosystem. Addresses #52.
- Loading branch information
Showing
11 changed files
with
104 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "http-body-util" | ||
version = "0.4.4" | ||
authors = [ | ||
"Carl Lerche <me@carllerche.com>", | ||
"Lucio Franco <luciofranco14@gmail.com>", | ||
"Sean McArthur <sean@seanmonstar.com>", | ||
] | ||
edition = "2018" | ||
readme = "README.md" | ||
documentation = "https://docs.rs/http-body-util" | ||
repository = "https://github.com/hyperium/http-body" | ||
license = "MIT" | ||
description = """ | ||
Combinators and adapters for HTTP request or response bodies. | ||
""" | ||
keywords = ["http"] | ||
categories = ["web-programming"] | ||
resolver = "2" | ||
|
||
[dependencies] | ||
bytes = "1" | ||
http = "0.2" | ||
http-body = { path = ".." } | ||
pin-project-lite = "0.2" | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1", features = ["macros", "rt"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::Body; | ||
use http_body::Body; | ||
use bytes::Buf; | ||
use pin_project_lite::pin_project; | ||
use std::{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use super::{Body, SizeHint}; | ||
use http_body::{Body, SizeHint}; | ||
use bytes::Buf; | ||
use http::HeaderMap; | ||
use std::{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#![deny( | ||
missing_debug_implementations, | ||
missing_docs, | ||
unreachable_pub, | ||
broken_intra_doc_links | ||
)] | ||
#![cfg_attr(test, deny(warnings))] | ||
|
||
//! Utilities for [`http_body::Body`]. | ||
//! | ||
//! [`BodyExt`] adds extensions to the common trait. | ||
//! | ||
//! [`Empty`] and [`Full`] provide simple implementations. | ||
|
||
pub mod combinators; | ||
mod empty; | ||
mod full; | ||
|
||
pub use self::empty::Empty; | ||
pub use self::full::Full; | ||
use self::combinators::{BoxBody, MapData, MapErr, UnsyncBoxBody}; | ||
|
||
/// An extension trait for [`http_body::Body`] adding various combinators and adapters | ||
pub trait BodyExt: http_body::Body { | ||
/// Maps this body's data value to a different value. | ||
fn map_data<F, B>(self, f: F) -> MapData<Self, F> | ||
where | ||
Self: Sized, | ||
F: FnMut(Self::Data) -> B, | ||
B: bytes::Buf, | ||
{ | ||
MapData::new(self, f) | ||
} | ||
|
||
/// Maps this body's error value to a different value. | ||
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> | ||
where | ||
Self: Sized, | ||
F: FnMut(Self::Error) -> E, | ||
{ | ||
MapErr::new(self, f) | ||
} | ||
|
||
/// Turn this body into a boxed trait object. | ||
fn boxed(self) -> BoxBody<Self::Data, Self::Error> | ||
where | ||
Self: Sized + Send + Sync + 'static, | ||
{ | ||
BoxBody::new(self) | ||
} | ||
|
||
/// Turn this body into a boxed trait object that is !Sync. | ||
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error> | ||
where | ||
Self: Sized + Send + 'static, | ||
{ | ||
UnsyncBoxBody::new(self) | ||
} | ||
} | ||
|
||
impl<T: ?Sized> BodyExt for T where T: http_body::Body {} |