mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Add root-default endpoint creation macro
This commit is contained in:
@@ -10,22 +10,19 @@
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
use unshell::create_endpoint;
|
||||
use unshell::leaves::remote_shell;
|
||||
use unshell::protocol::tree::{EndpointOutcome, LocalEvent, ProtocolEndpoint};
|
||||
use unshell::protocol::tree::{Endpoint, EndpointOutcome, LocalEvent, ProtocolEndpoint};
|
||||
use unshell::protocol::{INTROSPECTION_PROCEDURE_ID, LeafIntrospection};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut endpoint: ProtocolEndpoint =
|
||||
create_endpoint!("agent", remote_shell::endpoint::RemoteShell::default());
|
||||
let leaf_spec = remote_shell::endpoint::RemoteShell::protocol_leaf_spec();
|
||||
let mut endpoint = ProtocolEndpoint::new(
|
||||
agent_path(),
|
||||
Some(Vec::new()),
|
||||
Vec::new(),
|
||||
vec![leaf_spec.clone()],
|
||||
);
|
||||
|
||||
let hook_id = endpoint.allocate_hook_id();
|
||||
let outcome = endpoint.send_call(
|
||||
agent_path(),
|
||||
Vec::new(),
|
||||
Some(remote_shell::endpoint::RemoteShell::protocol_leaf_name()),
|
||||
INTROSPECTION_PROCEDURE_ID,
|
||||
Some(hook_id),
|
||||
@@ -41,13 +38,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
"remote-shell examples normally listen on {}",
|
||||
remote_shell::endpoint::LISTEN_ADDR
|
||||
);
|
||||
println!("endpoint path: {:?}", agent_path());
|
||||
println!("endpoint id: {:?}", endpoint.local_id());
|
||||
println!("endpoint path: {:?}", endpoint.path());
|
||||
println!("declared leaf: {}", leaf_spec.name);
|
||||
println!("leaf: {}", payload.leaf_name);
|
||||
println!("procedures: {:?}", payload.procedures);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn agent_path() -> Vec<String> {
|
||||
vec![String::from("agent")]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user