mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Add compile-time leaf declarations
Introduce a function-like leaf declaration macro, bind endpoint and TUI hosts to shared generated metadata, and move remote shell endpoint construction out of the leaf module into the examples and runtime assembly code.
This commit is contained in:
@@ -10,12 +10,24 @@ use std::sync::mpsc::RecvTimeoutError;
|
||||
use std::time::Duration;
|
||||
|
||||
use unshell::leaves::remote_shell;
|
||||
use unshell::protocol::tree::Ingress;
|
||||
use unshell::protocol::tree::{Ingress, ProcedureRuntime, ProtocolEndpoint};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut stream = TcpStream::connect(remote_shell::endpoint::LISTEN_ADDR)?;
|
||||
let frame_rx = remote_shell::endpoint::spawn_frame_reader(stream.try_clone()?);
|
||||
let mut runtime = remote_shell::endpoint::build_agent_runtime();
|
||||
let endpoint = ProtocolEndpoint::new(
|
||||
agent_path(),
|
||||
Some(Vec::new()),
|
||||
Vec::new(),
|
||||
vec![remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_spec()],
|
||||
);
|
||||
let mut runtime = ProcedureRuntime::<
|
||||
remote_shell::endpoint::RemoteShellEndpoint,
|
||||
remote_shell::endpoint::Open,
|
||||
>::new(
|
||||
endpoint,
|
||||
remote_shell::endpoint::RemoteShellEndpoint::default(),
|
||||
);
|
||||
|
||||
println!(
|
||||
"connected to controller at {}",
|
||||
@@ -39,3 +51,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn agent_path() -> Vec<String> {
|
||||
vec![String::from("agent")]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ use std::net::TcpListener;
|
||||
use unshell::leaves::remote_shell;
|
||||
use unshell::leaves::remote_shell::OpenRequest;
|
||||
use unshell::protocol::tree::encode_call_reply;
|
||||
use unshell::protocol::tree::{Endpoint, EndpointOutcome, Ingress, LocalEvent};
|
||||
use unshell::protocol::tree::{
|
||||
ChildRoute, Endpoint, EndpointOutcome, Ingress, LocalEvent, ProtocolEndpoint,
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let listener = TcpListener::bind(remote_shell::endpoint::LISTEN_ADDR)?;
|
||||
@@ -19,10 +21,15 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("accepted endpoint connection from {peer_addr}");
|
||||
|
||||
let frame_rx = remote_shell::endpoint::spawn_frame_reader(stream.try_clone()?);
|
||||
let mut endpoint = remote_shell::endpoint::build_controller_endpoint();
|
||||
let mut endpoint = ProtocolEndpoint::new(
|
||||
Vec::new(),
|
||||
None,
|
||||
vec![ChildRoute::registered(agent_path())],
|
||||
Vec::new(),
|
||||
);
|
||||
let hook_id = endpoint.allocate_hook_id();
|
||||
let shell_leaf_name = remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_name();
|
||||
let open_procedure = remote_shell::endpoint::ProcedureOpen::protocol_procedure_id();
|
||||
let open_procedure = remote_shell::endpoint::Open::protocol_procedure_id();
|
||||
|
||||
remote_shell::endpoint::send_forward(
|
||||
&mut stream,
|
||||
|
||||
@@ -16,10 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
agent_path(),
|
||||
Some(Vec::new()),
|
||||
Vec::new(),
|
||||
vec![unshell::protocol::tree::LeafSpec {
|
||||
name: remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_name(),
|
||||
procedures: vec![remote_shell::endpoint::ProcedureOpen::protocol_procedure_id()],
|
||||
}],
|
||||
vec![remote_shell::endpoint::RemoteShellEndpoint::protocol_leaf_spec()],
|
||||
);
|
||||
|
||||
let hook_id = endpoint.allocate_hook_id();
|
||||
|
||||
Reference in New Issue
Block a user