sausage-plugin part 2: import! with typed clients (sausage_interface::client_rs), TCP endpoints with rpc.endpoint, examples

Part 1 fixes: complete stdout writes, buffered stdin, Rust type names
in schemas, enum variant docs, -32603 for serde errors in handlers,
crate docs and modules. End-to-end check of a generated consumer through
a fake core.
This commit is contained in:
2026-10-23 00:35:45 +01:00
parent ae1cb4cc99
commit 8d3c163992
42 changed files with 3020 additions and 856 deletions
+25
View File
@@ -0,0 +1,25 @@
//! Consumer of the probe's actual discovered interface.
use sausage_plugin::{Result, rpc};
sausage_plugin::import!("probe");
struct Consumer;
#[rpc]
impl Consumer {
/// Route an imported call through the core.
async fn run(&self) -> Result<i32> {
Ok(probe::add(probe::Add { a: 2, b: 3 })
.detach()
.on_notify(|name, _| eprintln!("typed progress: {name}"))
.await? as i32)
}
/// Connect to the provider's endpoint and receive its notification.
async fn endpoint(&self) -> Result<u64> {
let control = probe::control::connect("/endpoint").await?;
control
.stats()
.on_notify(|name, _| eprintln!("endpoint notification: {name}"))
.await
}
}
fn main() {
sausage_plugin::run(Consumer)
}