diff --git a/src/lib.rs b/src/lib.rs index 3c9158d..9a83170 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ const PROTO: u16 = 3; pub trait Server: Send + Sync { fn mount(&self, dev: &Path) -> Result; fn open(&self, path: &Path, mount_id: u64) -> Result<(Option, u64), ()>; + fn open_dir(&self, path: &Path, mount_id: u64) -> Result<(Option, u64), ()>; } #[derive(Copy, Clone)] @@ -44,6 +45,19 @@ impl Client { ) .unwrap() } + + pub fn open_dir(self, path: &Path, mount_id: u64) -> Result<(Option, u64), ()> { + postcard::from_bytes( + &rpc::send_call( + self.0, + PROTO, + 2, + &postcard::to_stdvec(&(path, mount_id)).unwrap(), + ) + .get_return(), + ) + .unwrap() + } } pub fn register_server(server: Box) { @@ -67,5 +81,9 @@ fn callback(call: IncomingCall) { let (path, mount_id) = postcard::from_bytes(call.args()).unwrap(); let ret = postcard::to_stdvec(&server.open(path, mount_id)).unwrap(); call.send_return(&ret); + } else if call.func == 2 { + let (path, mount_id) = postcard::from_bytes(call.args()).unwrap(); + let ret = postcard::to_stdvec(&server.open_dir(path, mount_id)).unwrap(); + call.send_return(&ret); } }