| Crates.io | tinyudp |
| lib.rs | tinyudp |
| version | 0.6.0 |
| created_at | 2024-05-04 07:59:26.29125+00 |
| updated_at | 2025-05-23 12:08:58.40776+00 |
| description | A tiny abstraction for UDP. |
| homepage | |
| repository | https://github.com/vikpe/tinyudp |
| max_upload_size | |
| id | 1229453 |
| size | 16,446 |
A tiny abstraction for UDP in Rust
(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,
}
tinyudp::send("quake.se:28000", &b"hello").await?;
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);
},
};