15 releases (7 breaking)
0.8.1 | May 1, 2023 |
---|---|
0.7.2 | Apr 25, 2023 |
0.6.0 | Apr 15, 2023 |
0.5.2 | Apr 15, 2023 |
0.1.1 | May 30, 2019 |
#1415 in Network programming
Used in door-macros
59KB
790 lines
Rusty Doors
The goal of this crate is to expose the illumos Doors API in Rust. It exposes the native doors API verbatim, and also provides some moderately safer abstractions.
What are Doors?
A door is a file-like mechanism for interprocess communication, not unlike a named pipe or a UNIX Domain Socket. Client programs can invoke functions (called server procedures) in door servers if the door server has made a door available on the filesystem.
A server procedure is a function within the door server program that has a special, predefined signature. It is the entrypoint for the thread that is created (or awoken) to handle a client's door invocation.
A door server is a process that has created a door from one of its server procedures.
Example
A server procedure that simply doubles its input might look like this:
use doors::server::Door;
use doors::server::Request;
use doors::server::Response;
#[doors::server_procedure]
fn double(x: Request) -> Response<[u8; 1]> {
if x.data.len() > 0 {
return Response::new([x.data[0] * 2]);
} else {
// We were given nothing, and 2 times nothing is zero...
return Response::new([0]);
}
}
let door = Door::create(double).unwrap();
door.force_install("/tmp/double.door").unwrap();
A client program which invokes that server procedure might look something like this:
use doors::Client;
let client = Client::open("/tmp/double.door").unwrap();
let response = client.call_with_data(&[111]).unwrap();
assert_eq!(response.data()[0], 222);
Acknowledgements
- The social media preview image is due to Jim Choate under the terms of CC BY-NC 2.0.
- This work preceeds, but was reignited by oxidecomputer/rusty-doors.
Dependencies
~1.5MB
~39K SLoC