8 releases (5 breaking)
Uses new Rust 2024
| 0.6.0 | May 23, 2025 |
|---|---|
| 0.5.1 | Mar 29, 2025 |
| 0.4.0 | May 4, 2024 |
| 0.3.0 | May 4, 2024 |
| 0.1.0 | May 4, 2024 |
#3 in #async-udp
558 downloads per month
Used in 4 crates
9KB
167 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
~0.2–13MB
~86K SLoC