feat(host): add object publication and dispatch
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user