message-channel 0.0.1

A simple thread-safe message channel implementation
Documentation
  • Coverage
  • 70%
    7 out of 10 items documented4 out of 9 items with examples
  • Size
  • Source code size: 9.16 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • piot

📬 message-channel

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.

✨ Features

  • Single-Producer, Single-Consumer (SPSC): Only one Sender and one Receiver can interact with a channel.
  • Non-blocking Receiver: The try_recv method returns immediately, either with a message (Some) or indicating that the queue is empty (None).
  • Thread-Safe: Uses Mutex and Arc to safely share data between threads.

📦 Installation

To use message-channel, add it to your Cargo.toml:

[dependencies]
message-channel = "0.0.1"

🚀 Usage

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);
}

License

This project is licensed under the MIT License - see the LICENSE file for details.