mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Support module-inferred leaf hosts
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
//! Smallest in-process `RemoteShellLeaf` endpoint example.
|
||||
//! Smallest in-process `remote_shell` declaration example.
|
||||
//!
|
||||
//! This example hosts exactly one protocol endpoint with exactly one leaf, `RemoteShellLeaf`, and
|
||||
//! performs a local introspection request against that leaf. It does not open any sockets or spawn
|
||||
//! a shell process, so it is the easiest place to see how the endpoint and leaf metadata fit
|
||||
//! together.
|
||||
//! This example hosts exactly one protocol endpoint with exactly one leaf and performs a local
|
||||
//! introspection request against that leaf. The important detail is that the endpoint metadata is
|
||||
//! taken from `remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_spec()`, which is
|
||||
//! generated by the `leaf!` declaration in `unshell-leaves/src/remote_shell/mod.rs`.
|
||||
//!
|
||||
//! It does not open any sockets or spawn a shell process, so it is the easiest place to verify
|
||||
//! that the shared compile-time leaf declaration and the generated endpoint host metadata line up.
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
@@ -12,17 +15,18 @@ use unshell::protocol::tree::{EndpointOutcome, LocalEvent, ProtocolEndpoint};
|
||||
use unshell::protocol::{INTROSPECTION_PROCEDURE_ID, LeafIntrospection};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let leaf_spec = remote_shell::endpoint::RemoteShell::protocol_leaf_spec();
|
||||
let mut endpoint = ProtocolEndpoint::new(
|
||||
agent_path(),
|
||||
Some(Vec::new()),
|
||||
Vec::new(),
|
||||
vec![remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_spec()],
|
||||
vec![leaf_spec.clone()],
|
||||
);
|
||||
|
||||
let hook_id = endpoint.allocate_hook_id();
|
||||
let outcome = endpoint.send_call(
|
||||
agent_path(),
|
||||
Some(remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_name()),
|
||||
Some(remote_shell::endpoint::RemoteShell::protocol_leaf_name()),
|
||||
INTROSPECTION_PROCEDURE_ID,
|
||||
Some(hook_id),
|
||||
Vec::new(),
|
||||
@@ -38,6 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
remote_shell::endpoint::LISTEN_ADDR
|
||||
);
|
||||
println!("endpoint path: {:?}", agent_path());
|
||||
println!("declared leaf: {}", leaf_spec.name);
|
||||
println!("leaf: {}", payload.leaf_name);
|
||||
println!("procedures: {:?}", payload.procedures);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user