chiark / gitweb /
wip refactor body
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:45:57 +0000 (18:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:45:57 +0000 (18:45 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs

index 00a27696a39690c27b3916d4698e2ad81cda3da9..1d3328d83a6bf83c8582abae9ad42a883a0c1f56 100644 (file)
@@ -68,20 +68,28 @@ fn submit_request<'r, 'c:'r, C:HCC>(
        "#),
   );
 
+  macro_rules! content {
+    {} => {
+      itertools::chain![
+        array::IntoIter::new([
+          Ok::<Bytes,Void>( prefix1.into() ),
+          Ok::<Bytes,Void>( 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::<Bytes,Void>),
+        [ Ok::<Bytes,Void>( suffix.into() ) ],
+      ]
+    }
+  }
+
   let body = hyper::body::Body::wrap_stream(
-    futures::stream::iter(itertools::chain![
-      array::IntoIter::new([
-        Ok::<Bytes,Void>( prefix1.into() ),
-        Ok::<Bytes,Void>( 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::<Bytes,Void>),
-      [ Ok::<Bytes,Void>( suffix.into() ) ],
-    ])
+    futures::stream::iter(
+      content!()
+    )
   );
 
   let req = hyper::Request::post(&c.ic.url)