Expand description
§spsc: single producer, single consumer for no_std Rust
An entangled sync sender + async receiver pair. A minimalistic, runtime-agnostic implementation.
Have a look at oneshot if you need a
more-complete / more-complex / more-well tested implementation.
§Example
let (user_sender, user_receiver) = spsc::channel();
// You can use any runtime you like:
// tokio, smol, pollster, ... it works with everything!
let rx = tokio::spawn(async {
// Receiving is async:
// the call only returns once a value was sent,
// or the sender was dropped.
let user = user_receiver.await.unwrap();
assert_eq!(user, "Max Mustermann");
});
// Sending is synchronous:
// The call does not need to happen inside a runtime.
user_sender.send("Max Mustermann").unwrap();
rx.await.unwrap();§License
This project is tri-licensed under ISC OR MIT OR Apache-2.0. Contributions must be licensed under the same terms. Users may follow any one of these licenses, or all of them.
See the individual license texts at
Structs§
- Receiver
- Waits for the
Senderto send a value. - Recv
Error - An error returned from
receiver.await. - Send
Error - An error returned from
Sender::send(). - Sender
- Call
send()to send a value toReceiver.
Enums§
- TryRecv
Error - An error returned from
try_recv().