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

baton

A simple channel for receiving updates per field

4 releases

0.2.1 Jan 28, 2025
0.2.0 Jan 15, 2025
0.1.1 Jan 8, 2025
0.1.0 Dec 7, 2024

#813 in Asynchronous

Download history 147/week @ 2024-12-04 18/week @ 2024-12-11 135/week @ 2025-01-08 231/week @ 2025-01-15 98/week @ 2025-01-22 150/week @ 2025-01-29 41/week @ 2025-02-05 22/week @ 2025-02-12 51/week @ 2025-02-19 44/week @ 2025-02-26

170 downloads per month
Used in moq-web

MIT/Apache

8KB
100 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