pub struct HostedRpcOwnerCell { /* private fields */ }Expand description
Type-erased, parent-owned cell that holds the owner value behind a
Mutex and exposes a &self dispatch entry point. Constructed by the
macro-generated registration code on the parent (the DependencyConstructor
for a HostedRpc dep returns one of these wrapped in Arc<dyn Any>)
and kept alive in _hosted_owners for the suite’s lifetime.
Implementations§
Source§impl HostedRpcOwnerCell
impl HostedRpcOwnerCell
Sourcepub fn from_owner<T>(owner: T) -> HostedRpcOwnerCellwhere
T: HostedRpcDep,
pub fn from_owner<T>(owner: T) -> HostedRpcOwnerCellwhere
T: HostedRpcDep,
Wrap an owner value into a HostedRpcOwnerCell. The owner type must
implement HostedRpcDep.
Sourcepub fn dispatch(&self, method_idx: u32, args: &[u8]) -> Result<Vec<u8>, String>
pub fn dispatch(&self, method_idx: u32, args: &[u8]) -> Result<Vec<u8>, String>
Dispatch one method call. Catches owner panics and turns them into
Err("hosted rpc owner panicked: …") so the dispatcher loop never
dies. The lock is acquired inside the catch_unwind closure on
purpose: when the owner panics, the MutexGuard drops during the
unwind, which poisons the mutex. Every subsequent dispatch call
then short-circuits with the stable "hosted rpc owner poisoned"
error and does NOT retry the (possibly half-mutated) owner.