From: Ian Jackson Date: Sun, 1 Aug 2021 17:45:57 +0000 (+0100) Subject: wip refactor body X-Git-Tag: hippotat/1.0.0~401 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=e88178ba5955cfb63075c387c1d320568e59a020;p=hippotat.git wip refactor body Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index 00a2769..1d3328d 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -68,20 +68,28 @@ fn submit_request<'r, 'c:'r, C:HCC>( "#), ); + macro_rules! content { + {} => { + itertools::chain![ + array::IntoIter::new([ + Ok::( prefix1.into() ), + Ok::( prefix2.into() ), + ]).take( + if upbound.is_empty() { 1 } else { 2 } + ), + Itertools::intersperse( + upbound.into_iter().map(|u| Bytes::from(u)), + SLIP_END_SLICE.into() + ).map(Ok::), + [ Ok::( suffix.into() ) ], + ] + } + } + let body = hyper::body::Body::wrap_stream( - futures::stream::iter(itertools::chain![ - array::IntoIter::new([ - Ok::( prefix1.into() ), - Ok::( prefix2.into() ), - ]).take( - if upbound.is_empty() { 1 } else { 2 } - ), - Itertools::intersperse( - upbound.into_iter().map(|u| Bytes::from(u)), - SLIP_END_SLICE.into() - ).map(Ok::), - [ Ok::( suffix.into() ) ], - ]) + futures::stream::iter( + content!() + ) ); let req = hyper::Request::post(&c.ic.url)