| Crates.io | message-channel |
| lib.rs | message-channel |
| version | 0.0.1 |
| created_at | 2024-11-13 15:38:39.294647+00 |
| updated_at | 2024-11-13 15:38:39.294647+00 |
| description | A simple thread-safe message channel implementation |
| homepage | |
| repository | https://github.com/piot/message-channel |
| max_upload_size | |
| id | 1446672 |
| size | 9,509 |
This Rust library provides a simple, thread-safe channel implementation for message passing between
a single Sender and a single Receiver. The channel is non-blocking on the receiving end, making
it ideal for cases where you want to check for messages without waiting.
Sender and one Receiver can interact with a channel.try_recv method returns immediately, either with a message (Some) or indicating that the queue is empty (None).Mutex and Arc to safely share data between threads.To use message-channel, add it to your Cargo.toml:
[dependencies]
message-channel = "0.0.1"
Here's a simple example of how to use message-channel:
use message_channel::Channel;
fn main() {
let (sender, receiver) = Channel::create();
// Send a message
sender.send(42).unwrap();
// Receive a message
let message = receiver.recv().unwrap();
assert_eq!(message, 42);
}
This project is licensed under the MIT License - see the LICENSE file for details.