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.
31 lines
632 B
31 lines
632 B
//! Socket handlers
|
|
use super::*;
|
|
|
|
use tokio::io::{
|
|
AsyncWrite,
|
|
AsyncRead
|
|
};
|
|
use tokio::task::JoinHandle;
|
|
use futures::Future;
|
|
use cancel::*;
|
|
|
|
|
|
|
|
/// Handles a raw, opened socket
|
|
pub fn handle_socket_with_shutdown<R, W, C: cancel::CancelFuture + 'static + Send>(tx: W, rx: R, 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)),
|
|
}
|
|
})
|
|
}
|