|
|
@ -195,9 +195,14 @@ async fn main() {
|
|
|
|
async move {
|
|
|
|
async move {
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
tokio::spawn(gen::body(state, num, tx));
|
|
|
|
tokio::spawn(gen::body(state, num, tx));
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.map(move |x| {
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.filter_map(move |mut x| {
|
|
|
|
|
|
|
|
if x.trim_in_place().len() != 0 {
|
|
|
|
info!("{} <- {:?}", host, x);
|
|
|
|
info!("{} <- {:?}", host, x);
|
|
|
|
Ok::<_, std::convert::Infallible>(x)
|
|
|
|
x.push('\n');
|
|
|
|
|
|
|
|
Some(Ok::<_, std::convert::Infallible>(x))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
}))))
|
|
|
|
}))))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -213,16 +218,14 @@ async fn main() {
|
|
|
|
async move {
|
|
|
|
async move {
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
tokio::spawn(sentance::body(state, num, tx));
|
|
|
|
tokio::spawn(sentance::body(state, num, tx));
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.map(move |mut x| {
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.filter_map(move |mut x| {
|
|
|
|
|
|
|
|
if x.trim_in_place().len() != 0 {
|
|
|
|
info!("{} (sentance) <- {:?}", host, x);
|
|
|
|
info!("{} (sentance) <- {:?}", host, x);
|
|
|
|
// match x.chars().last() {
|
|
|
|
|
|
|
|
// Some(chr) if sanitise::is_sentance_boundary(chr) => {
|
|
|
|
|
|
|
|
// x.push(' ');
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// _ => (),
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
x.push(' ');
|
|
|
|
x.push(' ');
|
|
|
|
Ok::<_, std::convert::Infallible>(x)
|
|
|
|
Some(Ok::<_, std::convert::Infallible>(x))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
}))))
|
|
|
|
}))))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|