Skip to content

Commit 46d4d43

Browse files
committed
refactor(body): refactor incoming body feature config
1 parent b5a2248 commit 46d4d43

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/body/incoming/mod.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ enum Kind {
5757
}
5858

5959
impl Incoming {
60-
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
61-
pub(crate) fn channel(content_length: DecodedLength, wanter: bool) -> (Sender, Incoming) {
62-
let (tx, chan) = ChanBody::new(content_length, wanter);
63-
(tx, Incoming::new(Kind::Chan(chan)))
64-
}
65-
6660
fn new(kind: Kind) -> Incoming {
6761
Incoming { kind }
6862
}
@@ -71,22 +65,32 @@ impl Incoming {
7165
pub(crate) fn empty() -> Incoming {
7266
Incoming::new(Kind::Empty)
7367
}
68+
}
7469

75-
#[cfg(feature = "ffi")]
76-
pub(crate) fn ffi() -> Incoming {
77-
Incoming::new(Kind::Ffi(crate::ffi::UserBody::new()))
70+
#[cfg(any(feature = "client", feature = "server"))]
71+
impl Incoming {
72+
#[cfg(feature = "http1")]
73+
pub(crate) fn channel(content_length: DecodedLength, wanter: bool) -> (Sender, Incoming) {
74+
let (tx, chan) = ChanBody::new(content_length, wanter);
75+
(tx, Incoming::new(Kind::Chan(chan)))
7876
}
7977

80-
#[cfg(all(feature = "http2", any(feature = "client", feature = "server")))]
78+
#[cfg(feature = "http2")]
8179
pub(crate) fn h2(
8280
recv: ::h2::RecvStream,
8381
content_length: DecodedLength,
8482
ping: ping::Recorder,
8583
) -> Self {
8684
Incoming::new(Kind::H2(H2Body::new(recv, content_length, ping)))
8785
}
86+
}
87+
88+
#[cfg(feature = "ffi")]
89+
impl Incoming {
90+
pub(crate) fn ffi() -> Incoming {
91+
Incoming::new(Kind::Ffi(crate::ffi::UserBody::new()))
92+
}
8893

89-
#[cfg(feature = "ffi")]
9094
pub(crate) fn as_ffi_mut(&mut self) -> &mut crate::ffi::UserBody {
9195
match self.kind {
9296
Kind::Ffi(ref mut body) => return body,

0 commit comments

Comments
 (0)