Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move adapters to
http-body-util
(#56)
- Loading branch information
Showing
18 changed files
with
149 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,3 @@ | ||
[package] | ||
name = "http-body" | ||
# When releasing to crates.io: | ||
# - Remove path dependencies | ||
# - Update html_root_url. | ||
# - Update doc url | ||
# - Cargo.toml | ||
# - README.md | ||
# - Update CHANGELOG.md. | ||
# - Create "vx.y.z" git tag. | ||
version = "0.4.5" | ||
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" | ||
repository = "https://github.com/hyperium/http-body" | ||
license = "MIT" | ||
description = """ | ||
Trait representing an asynchronous, streaming, HTTP request or response body. | ||
""" | ||
keywords = ["http"] | ||
categories = ["web-programming"] | ||
|
||
[dependencies] | ||
bytes = "1" | ||
http = "0.2" | ||
pin-project-lite = "0.2" | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1", features = ["macros", "rt"] } | ||
[workspace] | ||
members = ["http-body", "http-body-util"] | ||
resolver = "2" |
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,3 @@ | ||
# Unreleased | ||
|
||
- Initial release, split from http-body 0.4.5. |
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,35 @@ | ||
[package] | ||
name = "http-body-util" | ||
# When releasing to crates.io: | ||
# - Remove path dependencies | ||
# - Update html_root_url. | ||
# - Update doc url | ||
# - Cargo.toml | ||
# - README.md | ||
# - Update CHANGELOG.md. | ||
# - Create "http-body-util-x.y.z" git tag. | ||
version = "0.1.0" | ||
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"] | ||
|
||
[dependencies] | ||
bytes = "1" | ||
http = "0.2" | ||
http-body = { path = "../http-body" } | ||
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
2 changes: 1 addition & 1 deletion
2
src/combinators/map_data.rs → http-body-util/src/combinators/map_data.rs
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
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
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,63 @@ | ||
#![deny( | ||
missing_debug_implementations, | ||
missing_docs, | ||
unreachable_pub, | ||
rustdoc::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; | ||
mod limited; | ||
|
||
use self::combinators::{BoxBody, MapData, MapErr, UnsyncBoxBody}; | ||
pub use self::empty::Empty; | ||
pub use self::full::Full; | ||
pub use self::limited::{LengthLimitError, Limited}; | ||
|
||
/// 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 {} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "http-body" | ||
# When releasing to crates.io: | ||
# - Remove path dependencies | ||
# - Update html_root_url. | ||
# - Update doc url | ||
# - Cargo.toml | ||
# - README.md | ||
# - Update CHANGELOG.md. | ||
# - Create "http-body-x.y.z" git tag. | ||
version = "0.4.5" | ||
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" | ||
repository = "https://github.com/hyperium/http-body" | ||
license = "MIT" | ||
description = """ | ||
Trait representing an asynchronous, streaming, HTTP request or response body. | ||
""" | ||
keywords = ["http"] | ||
categories = ["web-programming"] | ||
|
||
[dependencies] | ||
bytes = "1" | ||
http = "0.2" |
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.
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