7 releases (4 breaking)

Uses new Rust 2024

0.5.1 Mar 29, 2025
0.5.0 Mar 29, 2025
0.4.0 May 4, 2024
0.3.0 May 4, 2024
0.1.0 May 4, 2024

#1589 in Network programming

Download history 4/week @ 2025-02-12 4/week @ 2025-02-26 228/week @ 2025-03-26 33/week @ 2025-04-02 14/week @ 2025-04-09

275 downloads per month
Used in 4 crates

MIT license

7KB
97 lines

tinyudp Test crates docs.rs

A tiny abstraction for UDP in Rust

Overview

(async) tinyudp::send(address: impl ToSocketAddrs, message: &[u8]) -> Result<(), TinyudpError>
(async) tinyudp::send_and_receive(address: impl ToSocketAddrs, message: &[u8], read_options: &ReadOptions) -> Result<Vec<u8>, TinyudpError>

struct ReadOptions {
    pub timeout: Duration,
    pub buffer_size: usize,
}

Usage

Send

tinyudp::send("quake.se:28000", &b"hello").await?;

Send and receive

let options = tinyudp::ReadOptions{
    timeout: Some(Duration::from_secs(1)),
    buffer_size: 8 * 1024,
};

match tinyudp::send_and_receive("quake.se:28000", &b"hello", &options).await {
    Ok(response) => {
        println!("response: {:?}", response);
    },
    Err(e) => {
        println!("error: {:?}", e);
    },
};

Dependencies

~4–12MB
~122K SLoC