Skip to content

robertdfrench/rusty-doors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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 result = client.call_with_data(&[111]).unwrap();
assert_eq!(result.data()[0], 222);

Tests

Run make tests to run the unit tests, and run make all to run the full build pipeline.

Acknowledgements