Skip to content

Commit

Permalink
review: use &mut self method receivers
Browse files Browse the repository at this point in the history
this applies a review suggestion here:
https://github.com/hyperium/http-body/pull/100/files#r1399780355

this commit refactors the channel-backed body in hyperium#100, changing the
signature of `send_*` methods on the sender to require a mutable
reference.
  • Loading branch information
cratelyn committed Jan 6, 2025
1 parent 08aba95 commit 8f57b85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions http-body-util/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ pub struct Sender<D, E = std::convert::Infallible> {

impl<D, E> Sender<D, E> {
/// Send a frame on the channel.
pub async fn send(&self, frame: Frame<D>) -> Result<(), SendError> {
pub async fn send(&mut self, frame: Frame<D>) -> Result<(), SendError> {
self.tx_frame.send(frame).await.map_err(|_| SendError)
}

/// Send data on data channel.
pub async fn send_data(&self, buf: D) -> Result<(), SendError> {
pub async fn send_data(&mut self, buf: D) -> Result<(), SendError> {
self.send(Frame::data(buf)).await
}

/// Send trailers on trailers channel.
pub async fn send_trailers(&self, trailers: HeaderMap) -> Result<(), SendError> {
pub async fn send_trailers(&mut self, trailers: HeaderMap) -> Result<(), SendError> {
self.send(Frame::trailers(trailers)).await
}

Expand Down

0 comments on commit 8f57b85

Please sign in to comment.