#ips #posix #nix #receiver #m-queue #ipc-sender #ipc-receiver

rust_m_queue

OOP-like wrapper around nix's posix m_queue

11 releases (5 stable)

1.0.5-alpha.1 Dec 20, 2024
1.0.0 Dec 19, 2024
0.1.1 Dec 19, 2024
0.1.0 Dec 19, 2024

#312 in Unix APIs

Download history 608/week @ 2024-12-18 6/week @ 2024-12-25

614 downloads per month

MIT license

11KB
176 lines

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
}

Dependencies

~2.1–2.9MB
~63K SLoC