Skip to content

Commit 3c09567

Browse files
committed
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.
1 parent a97da64 commit 3c09567

File tree

11 files changed

+104
-55
lines changed

11 files changed

+104
-55
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
- name: Install Rust
2828
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
2929
- name: Run tests
30-
run: cargo test
30+
run: cargo test --workspace

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Trait representing an asynchronous, streaming, HTTP request or response body.
2424
"""
2525
keywords = ["http"]
2626
categories = ["web-programming"]
27+
resolver = "2"
28+
29+
[workspace]
30+
members = ["util"]
2731

2832
[dependencies]
2933
bytes = "1"
3034
http = "0.2"
31-
pin-project-lite = "0.2"
32-
33-
[dev-dependencies]
34-
tokio = { version = "1", features = ["macros", "rt"] }

src/lib.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@
1313
//!
1414
//! [`Body`]: trait.Body.html
1515
16-
mod empty;
17-
mod full;
1816
mod next;
1917
mod size_hint;
2018

21-
pub mod combinators;
22-
23-
pub use self::empty::Empty;
24-
pub use self::full::Full;
2519
pub use self::next::{Data, Trailers};
2620
pub use self::size_hint::SizeHint;
2721

28-
use self::combinators::{BoxBody, MapData, MapErr, UnsyncBoxBody};
2922
use bytes::Buf;
3023
use http::HeaderMap;
3124
use std::ops;
@@ -95,41 +88,6 @@ pub trait Body {
9588
{
9689
Trailers(self)
9790
}
98-
99-
/// Maps this body's data value to a different value.
100-
fn map_data<F, B>(self, f: F) -> MapData<Self, F>
101-
where
102-
Self: Sized,
103-
F: FnMut(Self::Data) -> B,
104-
B: Buf,
105-
{
106-
MapData::new(self, f)
107-
}
108-
109-
/// Maps this body's error value to a different value.
110-
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
111-
where
112-
Self: Sized,
113-
F: FnMut(Self::Error) -> E,
114-
{
115-
MapErr::new(self, f)
116-
}
117-
118-
/// Turn this body into a boxed trait object.
119-
fn boxed(self) -> BoxBody<Self::Data, Self::Error>
120-
where
121-
Self: Sized + Send + Sync + 'static,
122-
{
123-
BoxBody::new(self)
124-
}
125-
126-
/// Turn this body into a boxed trait object that is !Sync.
127-
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
128-
where
129-
Self: Sized + Send + 'static,
130-
{
131-
UnsyncBoxBody::new(self)
132-
}
13391
}
13492

13593
impl<T: Body + Unpin + ?Sized> Body for &mut T {

util/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "http-body-util"
3+
version = "0.4.4"
4+
authors = [
5+
"Carl Lerche <me@carllerche.com>",
6+
"Lucio Franco <luciofranco14@gmail.com>",
7+
"Sean McArthur <sean@seanmonstar.com>",
8+
]
9+
edition = "2018"
10+
readme = "README.md"
11+
documentation = "https://docs.rs/http-body-util"
12+
repository = "https://github.com/hyperium/http-body"
13+
license = "MIT"
14+
description = """
15+
Combinators and adapters for HTTP request or response bodies.
16+
"""
17+
keywords = ["http"]
18+
categories = ["web-programming"]
19+
resolver = "2"
20+
21+
[dependencies]
22+
bytes = "1"
23+
http = "0.2"
24+
http-body = { path = ".." }
25+
pin-project-lite = "0.2"
26+
27+
[dev-dependencies]
28+
tokio = { version = "1", features = ["macros", "rt"] }

src/combinators/box_body.rs renamed to util/src/combinators/box_body.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::Body;
1+
use crate::BodyExt as _;
2+
3+
use http_body::{Body, SizeHint};
24
use bytes::Buf;
35
use std::{
46
fmt,
@@ -60,7 +62,7 @@ where
6062
self.inner.is_end_stream()
6163
}
6264

63-
fn size_hint(&self) -> crate::SizeHint {
65+
fn size_hint(&self) -> SizeHint {
6466
self.inner.size_hint()
6567
}
6668
}
@@ -119,7 +121,7 @@ where
119121
self.inner.is_end_stream()
120122
}
121123

122-
fn size_hint(&self) -> crate::SizeHint {
124+
fn size_hint(&self) -> SizeHint {
123125
self.inner.size_hint()
124126
}
125127
}

src/combinators/map_data.rs renamed to util/src/combinators/map_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::Body;
1+
use http_body::Body;
22
use bytes::Buf;
33
use pin_project_lite::pin_project;
44
use std::{

src/combinators/map_err.rs renamed to util/src/combinators/map_err.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::Body;
1+
use http_body::{Body, SizeHint};
22
use pin_project_lite::pin_project;
33
use std::{
44
any::type_name,
@@ -79,7 +79,7 @@ where
7979
self.inner.is_end_stream()
8080
}
8181

82-
fn size_hint(&self) -> crate::SizeHint {
82+
fn size_hint(&self) -> SizeHint {
8383
self.inner.size_hint()
8484
}
8585
}
File renamed without changes.

src/empty.rs renamed to util/src/empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{Body, SizeHint};
1+
use http_body::{Body, SizeHint};
22
use bytes::Buf;
33
use http::HeaderMap;
44
use std::{

src/full.rs renamed to util/src/full.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Body, SizeHint};
1+
use http_body::{Body, SizeHint};
22
use bytes::{Buf, Bytes};
33
use http::HeaderMap;
44
use pin_project_lite::pin_project;

0 commit comments

Comments
 (0)