| Crates.io | rust_m_queue |
| lib.rs | rust_m_queue |
| version | 1.0.5-alpha.1 |
| created_at | 2024-12-19 20:20:29.441439+00 |
| updated_at | 2024-12-20 15:42:58.297097+00 |
| description | OOP-like wrapper around nix's posix m_queue |
| homepage | |
| repository | https://github.com/inclus16/rust_m_queue |
| max_upload_size | |
| id | 1489529 |
| size | 11,090 |
This library is a simple OOP-like wrapper around nix posix m_queue to communicate between processes through queue in unix environment.
It contains two classes: IpcReceiver and IpcSender.
Basic usage of IpcSender:
#[derive(Serialize)]
struct Message {
pub data: String,
}
const MESSAGE_SIZE: usize = 1024;
const QUEUE_NAME: &str = "/test_queue";
let sender = IpcSender::<MESSAGE_SIZE>::connect_to_queue(QUEUE_NAME).unwrap();
let message = Message {
data: String::from("test")
};
let priority = 3;
sender.send(message, priority).unwrap();
And IpcReceiver:
use serde::{Deserialize};
use rust_m_queue::receiver::IpcReceiver;
#[derive(Deserialise)]
struct Message {
pub data: String,
}
const MESSAGE_SIZE: usize = 1024;
const QUEUE_NAME: &str = "/test_queue";
let mut receiver = IpcReceiver::<MESSAGE_SIZE>::init(QUEUE_NAME, 10).unwrap();
loop{
let data = receiver.receive::<Message>().unwrap(); //thread blocking
}