From 144ef6b9f394aedb15a278c52723934ce3b7ce68 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Thu, 14 Jul 2022 22:33:17 -0700 Subject: [PATCH] allow ResponseValue to transfer ownership of interior Stream (#125) --- progenitor-client/src/progenitor_client.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/progenitor-client/src/progenitor_client.rs b/progenitor-client/src/progenitor_client.rs index 1a1a6cb..373ad63 100644 --- a/progenitor-client/src/progenitor_client.rs +++ b/progenitor-client/src/progenitor_client.rs @@ -16,11 +16,20 @@ use serde::{de::DeserializeOwned, Serialize}; /// Represents an untyped byte stream for both success and error responses. pub struct ByteStream( - Pin> + Send>>, + Pin> + Send + Sync>>, ); +impl ByteStream { + pub fn into_inner( + self, + ) -> Pin> + Send + Sync>> { + self.0 + } +} + impl Deref for ByteStream { - type Target = Pin> + Send>>; + type Target = + Pin> + Send + Sync>>; fn deref(&self) -> &Self::Target { &self.0 @@ -140,6 +149,15 @@ impl ResponseValue { } } +impl ResponseValue { + /// Take ownership of the stream of bytes underpinning this response + pub fn into_inner_stream( + self, + ) -> Pin> + Send + Sync>> { + self.into_inner().into_inner() + } +} + impl Deref for ResponseValue { type Target = T;