#ipc #windows #mailslot

mail_slot

A Rust implementation of the Windows Mailslot API

4 releases

0.1.3 Dec 12, 2019
0.1.2 Dec 11, 2019
0.1.1 Dec 11, 2019
0.1.0 Dec 11, 2019

#131 in Windows APIs

30 downloads per month

MIT license

10KB
173 lines

mail_slot

A Rust implementation of the Windows Mailslot API

Usage

The mailslot api is a Single Consumer Multiple Sender IPC system natively supported by windows. A single server can listen to a mail slot and any number of clients. Below is a naive example that counts to 10, printing the numbers to the terminal.

use mail_slot::{MailslotName, MailslotServer, MailslotClient};
let name = MailslotName::local("naive");
let mut server = MailslotServer::new(&name).unwrap();
let mut client = MailslotClient::new(&name).unwrap();
for i in 0..10 {
    client.send_message(i.to_string().as_bytes()).unwrap();
}
while let Some(msg) = server.get_next_unread().unwrap() {
    let msg_str = String::from_utf8(msg).unwrap();
    println!("message from client {}", msg_str);
}

lib.rs:

The mailslot api is a Single Consumer Multiple Sender IPC system natively supported by windows. A single server can listen to a mail slot and any number of clients. Below is a naive example that counts to 10, printing the numbers to the terminal.

use mail_slot::{MailslotName, MailslotServer, MailslotClient};
let name = MailslotName::local("naive");
let mut server = MailslotServer::new(&name).unwrap();
let mut client = MailslotClient::new(&name).unwrap();
for i in 0..10 {
    client.send_message(i.to_string().as_bytes()).unwrap();
}
while let Some(msg) = server.get_next_unread().unwrap() {
    let msg_str = String::from_utf8(msg).unwrap();
    println!("message from client {}", msg_str);
}

Dependencies

~225KB