You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rsh/src/sock.rs

29 lines
637 B

//! Socket handlers
use super::*;
use tokio::io::{
AsyncWrite,
AsyncRead
};
use tokio::task::JoinHandle;
use futures::Future;
use cancel::*;
/// Handles a raw socket
pub fn handle_socket_with_shutdown<R, W, C: cancel::CancelFuture + 'static + Send>(sock_read: R, sock_write: W, shutdown: C) -> JoinHandle<eyre::Result<()>>
where R: AsyncRead + Unpin + Send + 'static,
W: AsyncWrite + Unpin + Send + 'static
{
tokio::spawn(async move {
match {
with_cancel!(async move {
//TODO: How to handle reads+writes?
Ok(())
}, shutdown)
} {
Ok(v) => v,
Err(x) => Err(eyre::Report::from(x)),
}
})
}