Skip to main content

HostedRpcChannel

Struct HostedRpcChannel 

Source
pub struct HostedRpcChannel { /* private fields */ }
Expand description

Per-dep channel handed to HostedRpcDep::build_stub on the worker side.

The stub holds this channel and calls HostedRpcChannel::call from each of its method bodies; the channel takes care of dep-id routing, serialization framing, and waiting for the parent’s reply.

Implementations§

Source§

impl HostedRpcChannel

Source

pub fn new( dep_id: String, transport: Arc<dyn HostedRpcTransport>, ) -> HostedRpcChannel

Construct a channel that targets the dep identified by dep_id (a fully-qualified id) and uses the supplied transport.

Source

pub fn dep_id(&self) -> &str

The fully-qualified dep id this channel routes to. Stubs almost never need this directly, but it’s exposed for diagnostics and tests.

Source

pub fn call( &self, method_idx: u32, args: Vec<u8>, ) -> Result<Vec<u8>, HostedRpcError>

Send one method call and block until the parent replies. args are already-serialized bytes; the stub method body owns the choice of codec.

Temporal invariant — only call this while a test body is actually running. The transport assumes one HostedRpc request/reply pair per worker subprocess is in flight at a time and that the worker’s main IPC command loop is idle (it only reads Provide* / RunTest between tests). Specifically:

  • Do NOT call from HostedRpcDep::build_stub — see that method’s docs for why.
  • Do NOT call from background threads or detached tasks that outlive the test body — once the test returns the worker sends TestFinished and the parent’s next message will be a Provide* / RunTest, which the transport’s read side would then misinterpret as a reply.
  • Do NOT call from Drop / destructor-style cleanup or any teardown hook that may fire after the test body has returned — that is just another form of “outside the test body” and has the same IPC-framing-desync risk as a detached background thread.
  • Stub calls from inside the test body — directly or transitively from helpers the test body awaits/blocks on — are the supported shape.

Trait Implementations§

Source§

impl Clone for HostedRpcChannel

Source§

fn clone(&self) -> HostedRpcChannel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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.