allow ResponseValue<ByteStream> to transfer ownership of interior Stream (#125)
This commit is contained in:
parent
0c7cace799
commit
144ef6b9f3
|
@ -16,11 +16,20 @@ use serde::{de::DeserializeOwned, Serialize};
|
||||||
|
|
||||||
/// Represents an untyped byte stream for both success and error responses.
|
/// Represents an untyped byte stream for both success and error responses.
|
||||||
pub struct ByteStream(
|
pub struct ByteStream(
|
||||||
Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send>>,
|
Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send + Sync>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl ByteStream {
|
||||||
|
pub fn into_inner(
|
||||||
|
self,
|
||||||
|
) -> Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send + Sync>> {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deref for ByteStream {
|
impl Deref for ByteStream {
|
||||||
type Target = Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send>>;
|
type Target =
|
||||||
|
Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send + Sync>>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -140,6 +149,15 @@ impl<T> ResponseValue<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ResponseValue<ByteStream> {
|
||||||
|
/// Take ownership of the stream of bytes underpinning this response
|
||||||
|
pub fn into_inner_stream(
|
||||||
|
self,
|
||||||
|
) -> Pin<Box<dyn Stream<Item = reqwest::Result<Bytes>> + Send + Sync>> {
|
||||||
|
self.into_inner().into_inner()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Deref for ResponseValue<T> {
|
impl<T> Deref for ResponseValue<T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue