streamline loop_server stream construction

This commit is contained in:
Tangent 128 2018-04-05 20:16:37 -04:00
parent 7d4a26dad5
commit 9ca384f9da

View file

@ -6,7 +6,6 @@ use std::env::args;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use futures::future::FutureResult; use futures::future::FutureResult;
use futures::stream::once;
use futures::stream::repeat; use futures::stream::repeat;
use futures::stream::Stream; use futures::stream::Stream;
use lab_ebml::chunk::{Chunk, WebmStream, ChunkingError}; use lab_ebml::chunk::{Chunk, WebmStream, ChunkingError};
@ -32,11 +31,8 @@ impl Service for WebmServer {
let response = match (req.method(), req.path()) { let response = match (req.method(), req.path()) {
(&Get, "/loop") => { (&Get, "/loop") => {
let stream: BodyStream<Vec<u8>> = Box::new( let stream: BodyStream<Vec<u8>> = Box::new(
repeat(()).take(3) repeat::<&[u8], ()>(SRC_FILE).take(5)
.map(|()| { .parse_ebml().chunk_webm().fix_timecodes()
once::<&[u8], ()>(Ok(SRC_FILE)).parse_ebml().chunk_webm()
}).flatten()
.fix_timecodes()
.map_err(|err| match err { .map_err(|err| match err {
ChunkingError::IoError(io_err) => hyper::Error::Io(io_err), ChunkingError::IoError(io_err) => hyper::Error::Io(io_err),
ChunkingError::OtherError(_) => hyper::Error::Incomplete ChunkingError::OtherError(_) => hyper::Error::Incomplete