2018-10-21 23:09:37 +00:00
|
|
|
use std::io::stdin;
|
2018-04-12 04:14:16 +00:00
|
|
|
|
2018-10-21 23:09:37 +00:00
|
|
|
use bytes::{
|
|
|
|
Buf,
|
|
|
|
IntoBuf
|
2018-04-14 22:18:50 +00:00
|
|
|
};
|
2018-10-21 23:09:37 +00:00
|
|
|
use futures::prelude::*;
|
2018-09-21 00:58:51 +00:00
|
|
|
use tokio_io::io::AllowStdIo;
|
|
|
|
use tokio_codec::{
|
|
|
|
BytesCodec,
|
|
|
|
FramedRead
|
2018-04-12 04:14:16 +00:00
|
|
|
};
|
2018-10-21 06:25:24 +00:00
|
|
|
use webmetro::error::WebmetroError;
|
2018-04-12 04:14:16 +00:00
|
|
|
|
2018-04-12 01:54:02 +00:00
|
|
|
pub mod dump;
|
2018-04-12 06:03:46 +00:00
|
|
|
pub mod filter;
|
2018-04-11 05:39:28 +00:00
|
|
|
pub mod relay;
|
2018-04-15 05:43:23 +00:00
|
|
|
pub mod send;
|
2018-04-12 04:14:16 +00:00
|
|
|
|
2018-04-14 22:18:50 +00:00
|
|
|
/// An adapter that makes chunks of bytes from stdin available as a Stream;
|
|
|
|
/// is NOT actually async, and just uses blocking read. Don't use more than
|
|
|
|
/// one at once, who knows who gets which bytes.
|
2018-10-21 23:09:37 +00:00
|
|
|
pub fn stdin_stream() -> impl Stream<Item = impl Buf, Error = WebmetroError> {
|
2018-04-14 22:18:50 +00:00
|
|
|
FramedRead::new(AllowStdIo::new(stdin()), BytesCodec::new())
|
2018-10-21 23:09:37 +00:00
|
|
|
.map(|bytes| bytes.into_buf())
|
2019-01-03 05:40:12 +00:00
|
|
|
.map_err(WebmetroError::from)
|
2018-04-12 04:14:16 +00:00
|
|
|
}
|