feat(host): add object publication and dispatch

This commit is contained in:
2026-09-28 23:36:50 +09:00
parent 3f94d48f04
commit 32f3fb6fb1
11 changed files with 1267 additions and 8 deletions
+15
View File
@@ -92,6 +92,21 @@ pub trait InterfaceDefinition {
fn descriptor() -> InterfaceDescriptor;
}
/// Typed dispatch implemented by every generated interface companion.
///
/// `T` must implement the Rust interface trait associated with this definition.
/// Host runtimes use this bound when an interface is explicitly exposed, so an
/// object that does not implement that interface is rejected at compile time.
pub trait InterfaceImplementation<T>: InterfaceDefinition {
/// Validates, decodes, and dispatches one operation to `implementation`,
/// then encodes and validates its result.
fn dispatch(
implementation: &T,
operation: &str,
arguments: Vec<NamedValue>,
) -> Result<Option<Value>, DispatchError>;
}
/// Result convention required for generated interface operations.
///
/// `Ok(T)` is an application result, including domain-failure union cases.