Expand description
Runtime agnostic, non-blocking, non-exclusive async UDP networking.
futures-udp provides two key structs:
These structs implement the futures-rs traits Stream & Sink respectively but are tested
and known to work with both tokio & futures-rs runtimes. (tokio tests performed in a
downstream crate, I’ll add them here soon so to make sure this never breaks)
§Why?
- I usually don’t want to be forced to bring
tokiointo my dependency tree unless I want to use it as my runtime. I think the runtime choice should be left to the final binary. futures-rsis a lot lighter weight and provided by rust-lang, so I chose that for the base traits. They are cross-compatible withtokio.- Working with a bare
UdpSocketis “a bit hard”, doing it async is “a bit more hard”. AddingStream&Sinksemantics makes it “nice”. - Despite the docs futures_net::UdpSocket creates a blocking socket, which is locked for exclusive use. (Opening a ticket TBD)
§Stability & MSRV
I’ve chosen to rely on two experimental features, while this crate is in v0.x.y, as I feel they add significant value to the API. I also believe in supporting language development and generating feedback to features as they near stabilisation.
This crate will not move to v1.x.y until both features are stabilised, or I decide to stop using them. Realistically, however, they will be stable while I allow this API to go through a “settling-in” phase before fixing it at v1.0.0
🔬 Experimental Features
This crate makes use of the following experimental features:
#![feature(never_type)][final stages of stabilisation]#![feature(bool_to_result)][in FCP as of 2026-04-25]This list includes any unstable features used by direct & transitive dependencies (currently, none).
Both are so close to being part of stable rust that I chose to use them here.
You do not need to enable these in your own code, the list is for information only. But currently you do need to use nightly to take advantage of this crate.
§Stability guarantees
We run automated tests every month to ensure no fundamental changes affect this crate and test every PR against the current nightly, as well as the current equivalent beta & stable. If you find an issue before we do, please raise an issue on github.
§MSRV
For those of you working with a pinned nightly (etc.) this crate supports the equivalent of 1.90.0 onwards. We use autocfg to seamlessly handle features which have been stabilised since then.
§Dependencies
We deliberately keep the dependency list short and pay attention to any transitive dependencies we bring in.
futures-rs(for the Stream & Sink traits)futures-net(for the underlying UdpSocket)socket2(to set the socket to non-blocking, non-exclusive)
Structs§
- UdpSink
- A non-blocking async UdpSocket with ability to
send_toviasendand make use of all the niceties that come withfutures::sink::Sinkandfutures::sink::SinkExt. - UdpStream
- A non-blocking async UdpSocket with ability to
recv_fromvianextandsend_toviapush.
Traits§
- Evented
UdpSocket - Basic functions on a struct wrapping a
PollEvented<sys::net::UdpSocket>