From 49afd94f8d084ac028920c1785b2ddb05c13bef3 Mon Sep 17 00:00:00 2001 From: Hampus Lidin Date: Wed, 2 Sep 2020 00:01:07 +0200 Subject: Implement multiple chunk streams in build function for images (#232) Co-authored-by: Hampus Lidin --- src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 06b31a1..c810ea5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,9 +170,18 @@ impl<'a> Images<'a> { None::>, ); - let value_stream = chunk_stream.and_then(|chunk| async move { - serde_json::from_slice(&chunk).map_err(Error::from) - }); + let value_stream = chunk_stream + .and_then(|chunk| async move { + let stream = futures_util::stream::iter( + serde_json::Deserializer::from_slice(&chunk) + .into_iter() + .collect::>(), + ) + .map_err(Error::from); + + Ok(stream) + }) + .try_flatten(); Ok(value_stream) } -- cgit v1.2.3