tinyudp

Crates.iotinyudp
lib.rstinyudp
version0.6.0
created_at2024-05-04 07:59:26.29125+00
updated_at2025-05-23 12:08:58.40776+00
descriptionA tiny abstraction for UDP.
homepage
repositoryhttps://github.com/vikpe/tinyudp
max_upload_size
id1229453
size16,446
Viktor Persson (vikpe)

documentation

README

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);
    },
};
Commit count: 14

cargo fmt