tinyudp

A tiny abstraction for UDP in Rust
Overview
send
Usage
Send
.await?;
send
Send and receive
let options = ReadOptions;
match send_and_receive.await ;
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);
},
};