Skip to content

Commit

Permalink
refactor client body (#1464)
Browse files Browse the repository at this point in the history
* remove unnecessary heap pin

Signed-off-by: tottoto <[email protected]>

* use Poll::map_err method to convert error type

Signed-off-by: tottoto <[email protected]>

---------

Signed-off-by: tottoto <[email protected]>
  • Loading branch information
tottoto authored Apr 9, 2024
1 parent 2fb575c commit bf62f56
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions kube-client/src/client/body.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{
error::Error as StdError,
fmt,
pin::Pin,
task::{ready, Context, Poll},
pin::{pin, Pin},
task::{Context, Poll},
};

use bytes::Bytes;
Expand Down Expand Up @@ -87,10 +87,7 @@ impl HttpBody for Body {
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
match &mut self.kind {
Kind::Once(val) => Poll::Ready(val.take().map(|bytes| Ok(Frame::data(bytes)))),
Kind::Wrap(body) => Poll::Ready(
ready!(Pin::new(body).poll_frame(cx))
.map(|opt_chunk| opt_chunk.map_err(crate::Error::Service)),
),
Kind::Wrap(body) => pin!(body).poll_frame(cx).map_err(crate::Error::Service),
}
}

Expand Down

0 comments on commit bf62f56

Please sign in to comment.