pulse_http 0.2.0

Async HTTP/1.1 framework on Tokio — raw TCP, routing, middleware, no Hyper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::time::Duration;
use tokio::{io::AsyncWriteExt, net::TcpStream, time::timeout};

pub async fn write_with_timeout(
    stream: &mut TcpStream,
    buf: &[u8],
    write_timeout_sec: u64,
) -> Result<(), ()> {
    match timeout(
        Duration::from_secs(write_timeout_sec),
        stream.write_all(buf),
    )
    .await
    {
        Ok(Ok(_)) => Ok(()),
        _ => Err(()),
    }
}