#ipc #remote-procedure #schema-validation #rpc #inter-process #channel #ipc-channel

ipc-rpc

A wrapper over servo/ipc-channel which provides many high level features

9 stable releases

1.2.6 Oct 17, 2022
1.2.5 Oct 16, 2022
1.2.2 Sep 13, 2022
1.1.0 Sep 13, 2022
1.0.1 Sep 13, 2022

#348 in Asynchronous

Download history 65/week @ 2024-07-20 200/week @ 2024-07-27 64/week @ 2024-08-03 64/week @ 2024-08-10 92/week @ 2024-08-17 83/week @ 2024-08-24 115/week @ 2024-08-31 92/week @ 2024-09-07 52/week @ 2024-09-14 124/week @ 2024-09-21 59/week @ 2024-09-28 68/week @ 2024-10-05 74/week @ 2024-10-12 57/week @ 2024-10-19 63/week @ 2024-10-26 65/week @ 2024-11-02

271 downloads per month
Used in hyprsome

MIT license

82KB
1.5K SLoC

ipc-rpc

Inter-Process Communication Remote Procedure Calls

Crates.io

Documentation

This Rust library is a wrapper over servo/ipc-channel that adds many new features.

  • Bi-directional communication by default.
  • Future based reply mechanism allows easy and accurate pairing of requests and responses.
  • (Optional, enabled by default) Validation on startup that message schemas match between the server and client. No more debugging bad deserializations. Relies on schemars.
  • Streamlined initialization of IPC channels for common use cases, while still allowing for more flexible and robust dynamic initialization in more unique scenarios.

Compatible with anything that can run servo/ipc-channel, which at time of writing includes

  • Windows
  • MacOS
  • Linux
  • FreeBSD
  • OpenBSD

Additionally, servo/ipc-channel supports the following platforms but only while in inprocess mode, which is not capable of communication between processes.

  • Android
  • iOS
  • WASI

tokio

This crate uses the tokio runtime for executing futures, and it is a hard requirement that users of ipc-rpc must use tokio. There are no plans to add support for other executors, but sufficient demand for other executors may change that.

Cargo features

This crate exposes one feature, message-schema-validation, which is on by default. This enables functionality related to the schemars crate. When enabled, the software will attempt to validate the user message schema on initialization of the connection. Failure to validate is not a critical failure, and won't crash the program. An error will be emitted in the logs, and this status can be retrieved programmatically via many functions, all called schema_validated().

If you decide that a failure to validate the schema should be a critical failure you can add the following line of code to your program for execution after a connection is established.

Server

server.schema_validated().await.unwrap().assert_success();

Client

client.schema_validated().await.unwrap().assert_success();

Running the examples

The examples include a client and a server which are meant to be run together. The sequence for using them is

cargo build --examples
cargo run --example server

The server launches the client as part of its operation.

Limitations

Much like servo/ipc-channel, servers may only serve one client. Overcoming this limitation would require work within servo/ipc-channel.

Dependencies

~9–20MB
~298K SLoC