Support module-inferred leaf hosts

This commit is contained in:
Michael Mikovsky
2026-04-26 15:19:33 -06:00
parent 54c44b407e
commit f16be8d64a
15 changed files with 275 additions and 267 deletions
+2 -5
View File
@@ -18,11 +18,8 @@ struct EchoLeaf {
prefix: String,
}
leaf! {
id = "org.example.v1.echo",
endpoint_struct = EchoLeaf,
procedures = ["echo"],
}
#[leaf(id = "org.example.v1.echo", endpoint_struct = EchoLeaf, procedures = ["echo"])]
struct Echo;
#[derive(Archive, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
struct EchoRequest {
@@ -17,11 +17,8 @@ impl ProcedureMetadata for Reset {
const PROCEDURE_SUFFIX: &'static str = "reset";
}
leaf! {
id = "org.example.v1.demo",
procedures = [Open, Reset],
endpoint_struct = EndpointHost,
}
#[leaf(id = "org.example.v1.demo", procedures = [Open, Reset], endpoint_struct = EndpointHost)]
struct Demo;
struct EndpointHalf;
struct TuiHalf;
@@ -32,7 +29,7 @@ impl ProcedureMetadata for Connect {
const PROCEDURE_SUFFIX: &'static str = "connect";
}
leaf! {
#[leaf(
name = "chat",
org = "org",
product = "example",
@@ -40,7 +37,8 @@ leaf! {
procedures = [Connect],
endpoint_struct = EndpointHalf,
tui_struct = TuiHalf,
}
)]
struct Chat;
struct TuiOnly;
struct Tail;
@@ -50,11 +48,8 @@ impl ProcedureMetadata for Tail {
const PROCEDURE_SUFFIX: &'static str = "tail";
}
leaf! {
id = "org.example.v1.transcript",
procedures = [Tail],
tui_struct = TuiOnly,
}
#[leaf(id = "org.example.v1.transcript", procedures = [Tail], tui_struct = TuiOnly)]
struct Transcript;
#[test]
fn leaf_declaration_generates_endpoint_host_metadata() {
@@ -17,11 +17,8 @@ struct StreamLeaf {
sessions: BTreeMap<HookKey, ProcedureOpen>,
}
leaf! {
id = "org.example.v1.stream",
procedures = [ProcedureOpen],
endpoint_struct = StreamLeaf,
}
#[leaf(id = "org.example.v1.stream", procedures = [ProcedureOpen], endpoint_struct = StreamLeaf)]
struct Stream;
impl ProcedureStore<ProcedureOpen> for StreamLeaf {
fn procedure_sessions(&mut self) -> &mut BTreeMap<HookKey, ProcedureOpen> {
@@ -146,11 +143,8 @@ struct DuplexLeaf {
sessions: BTreeMap<HookKey, DuplexProcedure>,
}
leaf! {
id = "org.example.v1.duplex",
procedures = [DuplexProcedure],
endpoint_struct = DuplexLeaf,
}
#[leaf(id = "org.example.v1.duplex", procedures = [DuplexProcedure], endpoint_struct = DuplexLeaf)]
struct Duplex;
impl ProcedureStore<DuplexProcedure> for DuplexLeaf {
fn procedure_sessions(&mut self) -> &mut BTreeMap<HookKey, DuplexProcedure> {