Skip to content

Commit c63f737

Browse files
committed
refactor(body): rename Incoming new_channel constructor with channel
1 parent 6a321e7 commit c63f737

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/body/incoming.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const WANT_READY: usize = 2;
101101

102102
impl Incoming {
103103
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
104-
pub(crate) fn new_channel(content_length: DecodedLength, wanter: bool) -> (Sender, Incoming) {
104+
pub(crate) fn channel(content_length: DecodedLength, wanter: bool) -> (Sender, Incoming) {
105105
let (data_tx, data_rx) = mpsc::channel(0);
106106
let (trailers_tx, trailers_rx) = oneshot::channel();
107107

@@ -474,13 +474,13 @@ mod tests {
474474
eq(Incoming::empty(), SizeHint::with_exact(0), "empty");
475475

476476
eq(
477-
Incoming::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false).1,
477+
Incoming::channel(DecodedLength::CHUNKED, /*wanter =*/ false).1,
478478
SizeHint::new(),
479479
"channel",
480480
);
481481

482482
eq(
483-
Incoming::new_channel(DecodedLength::new(4), /*wanter =*/ false).1,
483+
Incoming::channel(DecodedLength::new(4), /*wanter =*/ false).1,
484484
SizeHint::with_exact(4),
485485
"channel with length",
486486
);
@@ -489,7 +489,7 @@ mod tests {
489489
#[cfg(not(miri))]
490490
#[tokio::test]
491491
async fn channel_abort() {
492-
let (tx, mut rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false);
492+
let (tx, mut rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter =*/ false);
493493

494494
tx.abort();
495495

@@ -500,8 +500,7 @@ mod tests {
500500
#[cfg(all(not(miri), feature = "http1"))]
501501
#[tokio::test]
502502
async fn channel_abort_when_buffer_is_full() {
503-
let (mut tx, mut rx) =
504-
Incoming::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false);
503+
let (mut tx, mut rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter =*/ false);
505504

506505
tx.try_send_data("chunk 1".into()).expect("send 1");
507506
// buffer is full, but can still send abort
@@ -523,7 +522,7 @@ mod tests {
523522
#[cfg(feature = "http1")]
524523
#[test]
525524
fn channel_buffers_one() {
526-
let (mut tx, _rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false);
525+
let (mut tx, _rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter =*/ false);
527526

528527
tx.try_send_data("chunk 1".into()).expect("send 1");
529528

@@ -535,14 +534,14 @@ mod tests {
535534
#[cfg(not(miri))]
536535
#[tokio::test]
537536
async fn channel_empty() {
538-
let (_, mut rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false);
537+
let (_, mut rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter =*/ false);
539538

540539
assert!(rx.frame().await.is_none());
541540
}
542541

543542
#[test]
544543
fn channel_ready() {
545-
let (mut tx, _rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter = */ false);
544+
let (mut tx, _rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter = */ false);
546545

547546
let mut tx_ready = tokio_test::task::spawn(tx.ready());
548547

@@ -551,8 +550,7 @@ mod tests {
551550

552551
#[test]
553552
fn channel_wanter() {
554-
let (mut tx, mut rx) =
555-
Incoming::new_channel(DecodedLength::CHUNKED, /*wanter = */ true);
553+
let (mut tx, mut rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter = */ true);
556554

557555
let mut tx_ready = tokio_test::task::spawn(tx.ready());
558556
let mut rx_data = tokio_test::task::spawn(rx.frame());
@@ -573,7 +571,7 @@ mod tests {
573571

574572
#[test]
575573
fn channel_notices_closure() {
576-
let (mut tx, rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter = */ true);
574+
let (mut tx, rx) = Incoming::channel(DecodedLength::CHUNKED, /*wanter = */ true);
577575

578576
let mut tx_ready = tokio_test::task::spawn(tx.ready());
579577

src/proto/h1/dispatch.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ where
261261
let body = match body_len {
262262
DecodedLength::ZERO => IncomingBody::empty(),
263263
other => {
264-
let (tx, rx) =
265-
IncomingBody::new_channel(other, wants.contains(Wants::EXPECT));
264+
let (tx, rx) = IncomingBody::channel(other, wants.contains(Wants::EXPECT));
266265
self.body_tx = Some(tx);
267266
rx
268267
}
@@ -733,7 +732,7 @@ mod tests {
733732
let _dispatcher = tokio::spawn(async move { dispatcher.await });
734733

735734
let body = {
736-
let (mut tx, body) = IncomingBody::new_channel(DecodedLength::new(4), false);
735+
let (mut tx, body) = IncomingBody::channel(DecodedLength::new(4), false);
737736
tx.try_send_data("reee".into()).unwrap();
738737
body
739738
};
@@ -765,7 +764,7 @@ mod tests {
765764

766765
let body = {
767766
let (mut tx, body) =
768-
IncomingBody::new_channel(DecodedLength::CHUNKED, /*wanter =*/ false);
767+
IncomingBody::channel(DecodedLength::CHUNKED, /*wanter =*/ false);
769768
tx.try_send_data("".into()).unwrap();
770769
body
771770
};

0 commit comments

Comments
 (0)