Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use upstream http_body_util::BodyDataStream #1514

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ hashbrown = "0.14.0"
home = "0.5.4"
http = "1.1.0"
http-body = "1.0.0"
http-body-util = "0.1.1"
http-body-util = "0.1.2"
hyper = "1.2.0"
hyper-util = "0.1.3"
hyper-openssl = "0.10.2"
Expand Down
5 changes: 0 additions & 5 deletions kube-client/src/client/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
};

use bytes::Bytes;
use futures::{stream::Stream, TryStreamExt};

Check warning on line 9 in kube-client/src/client/body.rs

View workflow job for this annotation

GitHub Actions / msrv

unused import: `TryStreamExt`

Check warning on line 9 in kube-client/src/client/body.rs

View workflow job for this annotation

GitHub Actions / msrv

unused import: `stream::Stream`
use http_body::{Body as HttpBody, Frame, SizeHint};
use http_body_util::{combinators::UnsyncBoxBody, BodyExt, BodyStream};

Check warning on line 11 in kube-client/src/client/body.rs

View workflow job for this annotation

GitHub Actions / msrv

unused import: `BodyStream`

/// A request body.
pub struct Body {
Expand Down Expand Up @@ -54,11 +54,6 @@
pub async fn collect_bytes(self) -> Result<Bytes, crate::Error> {
Ok(self.collect().await?.to_bytes())
}

// Convert this body into `Stream` which iterates only data frame skipping the other kind of frame
pub(crate) fn into_data_stream(self) -> impl Stream<Item = Result<Bytes, crate::Error>> {
Box::pin(BodyStream::new(self).try_filter_map(|frame| async { Ok(frame.into_data().ok()) }))
}
}

impl From<Bytes> for Body {
Expand Down
Loading