pub struct HostedBothShared { /* private fields */ }Expand description
Support type for #[test_dep(scope = Hosted, worker = both(T))].
One macro-emitted worker = both(T) registration is lowered into
two RegisteredDependency entries that both point at the same
parent-side owner — one for the descriptor (Hosted) view, one for
the RPC stub (HostedRpc) view. To keep the owner unique under
either view, both registrations route through a single
HostedBothShared cell created by the macro-emitted weak cache:
- the descriptor view asks for the cached descriptor bytes
(
HostedDep::descriptor/AsyncHostedDep::descriptoris only called once, on the first construction); - the RPC view asks for the inner
HostedRpcOwnerCell, so the parent-side dispatcher sees the same owner the descriptor was derived from; - the parent-side owner getter (used by downstream dep
constructors that take
&Owner) downcasts toHostedBothSharedand pulls outSelf::owner_arc, a type-erasedArc<T>of the very same owner the cell holds.
This is intentionally not a public end-user type; only the
macro-support helpers in [crate::__test_r_make_hosted_both_shared]
and friends construct one.
Implementations§
Sourcepub fn new(
descriptor_bytes: Vec<u8>,
owner: Arc<dyn Any + Sync + Send>,
rpc_cell: Arc<HostedRpcOwnerCell>,
) -> HostedBothShared
pub fn new( descriptor_bytes: Vec<u8>, owner: Arc<dyn Any + Sync + Send>, rpc_cell: Arc<HostedRpcOwnerCell>, ) -> HostedBothShared
Wrap a pre-computed descriptor + type-erased owner handle + RPC
owner cell for the both dep variant. The macro acquire helper
is the canonical construction site.
Sourcepub fn descriptor_bytes(&self) -> &[u8] ⓘ
pub fn descriptor_bytes(&self) -> &[u8] ⓘ
Borrow the cached descriptor bytes (computed once, on first construction).
Sourcepub fn rpc_cell(&self) -> Arc<HostedRpcOwnerCell>
pub fn rpc_cell(&self) -> Arc<HostedRpcOwnerCell>
Cheap clone of the inner RPC owner cell Arc. The
HostedRpc-view registration’s RpcFactory::owner_into_cell
hands this back to the runtime.