1 unstable release
0.1.0 | Dec 7, 2024 |
---|
#715 in Asynchronous
165 downloads per month
10KB
158 lines
Baton is a simple channel that only keeps the latest value. If you try to [Send] too quickly, then oops the [Recv] side will drop the baton.
Comes with a useful [Baton] macro to create a [Send] and [Recv] half for an entire struct. This allows you to send and receive updates independently for each field so it's clear what changed.
The API is inspired by tokio::sync::watch
but with a simpler design given the 1:1 nature.
Notably, Recv::recv will return a reference to the next value so you don't have to fumble around with changed()
state.
Additionally, there's no way to accidentally deadlock like with tokio::sync::watch::Ref
.
Dependencies
~2–7.5MB
~49K SLoC