Skip to main content

HostedBothShared

Struct HostedBothShared 

Source
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::descriptor is 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 to HostedBothShared and pulls out Self::owner_arc, a type-erased Arc<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§

Source§

impl HostedBothShared

Source

pub fn new( descriptor_bytes: Vec<u8>, owner: Arc<dyn Any + Send + Sync>, rpc_cell: Arc<HostedRpcOwnerCell>, ) -> Self

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.

Source

pub fn descriptor_bytes(&self) -> &[u8]

Borrow the cached descriptor bytes (computed once, on first construction).

Source

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.

Source

pub fn owner_arc<T>(&self) -> Arc<T>
where T: Send + Sync + 'static,

Downcast the type-erased owner handle back to Arc<T>. Used by the macro-generated owner getter so parent-side consumers that take &T can reach the singleton owner the RPC cell is holding behind a shared dispatcher.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.