#update #channel #send #field #receiving #recv #per

baton

A simple channel for receiving updates per field

3 unstable releases

new 0.2.0 Jan 15, 2025
0.1.1 Jan 8, 2025
0.1.0 Dec 7, 2024

#669 in Asynchronous

Download history 74/week @ 2024-12-01 89/week @ 2024-12-08 2/week @ 2024-12-15 121/week @ 2025-01-05 212/week @ 2025-01-12

333 downloads per month
Used in moq-web

MIT/Apache

9KB
148 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