Function actix_web_lab::body::channel
source · pub fn channel<E: Into<Box<dyn Error>>>() -> (Sender<E>, impl MessageBody)
Expand description
Returns a sender half and a receiver half that can be used as a body type.
§Examples
use std::convert::Infallible;
use actix_web_lab::body;
let (mut body_tx, body) = body::channel::<Infallible>();
let _ = web::block(move || {
body_tx
.send(web::Bytes::from_static(b"body from another thread"))
.unwrap();
});
HttpResponse::Ok().body(body)