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
275 downloads per month
Used in 4 crates
7KB
97 lines
tinyudp

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