#async-networking #synchronization #tokio #context #paradigms #familiar #p2p

no-std netbeam

a pure-rust asynchronous network synchronization crate (using tokio) that recreates familiar asynchronous paradigms but in a network context

6 releases (breaking)

0.8.0 Apr 10, 2024
0.7.0 Oct 4, 2023
0.6.0 Oct 4, 2023
0.5.0 May 1, 2023
0.3.0 Jan 18, 2023

#1039 in Network programming

Download history 4/week @ 2024-02-08 25/week @ 2024-02-15 16/week @ 2024-02-22 12/week @ 2024-02-29 8/week @ 2024-03-07 12/week @ 2024-03-14 2/week @ 2024-03-21 15/week @ 2024-03-28 82/week @ 2024-04-04 101/week @ 2024-04-11

201 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

190KB
4K SLoC

netbeam

This is a pure-rust asynchronous network synchronization crate (using tokio) that recreates familiar asynchronous paradigms but in a network context.

Let A and B be two nodes with a pre-established ordered+reliable connection to each other (e.g., over TCP, TLS, QUIC, etc)

  • join Given A executing function f_a -> r_a and B executing function f_b -> r_b, return r_a to A and r_b to B
  • try_join Given A executing function f_a -> Result<r_a> and B executing function f_b -> Result<r_b>, return Result<r_a> to A and Result<r_b> to B iff Result<r_a> = Ok(r_a) AND Result<r_b> = Ok(r_b). A global error is returned if either one of the nodes fails
  • select Given A executing function f_a -> r_a and B executing function f_b -> r_b, return r_a to A if r_a is computed first, or, return r_b to B if r_b is computed first
  • try_select Given A executing function f_a -> Result<r_a> and B executing function f_b -> Result<r_b>, return Result<r_a> to A if Result<r_a> is computed first AND Result<r_a> = Ok(r_a), or, return Result<r_b> to B if Result<r_b> is computed first AND Result<r_b> = Ok(r_b). Returns a global error if both nodes fail.

NetMutex: A mutual exclusion algorithm for sharing memory in a synchronized mannor between two nodes NetRwLock: Allows a single writer or many readers between two nodes

Additionally, there is a sync_start file that allows the synchronization of two operations at approximately the same time. Examples for every operation are in the source code under src/sync/[...]

Dependencies

~5–16MB
~167K SLoC