Skip to main content

Peer

Struct Peer 

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

The client, as seen from inside a handler.

Version 1 reverses direction for exactly one purpose: the endpoint that discovers a value is missing is never the process that can ask a person for it, and a stdio endpoint has no terminal to ask on. A callback is bounded by the deadline and the cancellation of the request that raised it, so it can neither outlive its caller nor keep an in-flight slot after the caller is gone.

Implementations§

Source§

impl Peer

Source

pub fn detached() -> Self

A peer that is not attached to a session: it advertises nothing, so Self::supports is always false and no callback is ever attempted.

This is what a handler exercised outside a live transport sees, and it is the same answer a real session gives for a client that advertised no callbacks, so a test never accidentally proves behavior a headless consumer would not get.

Source

pub fn supports(&self, method: &str) -> bool

Whether the client advertised one callback method. A handler MUST check this rather than calling and handling the failure: a client that cannot reach a person wants to be told so immediately, not after a deadline.

Source

pub async fn call<P: Serialize, R: DeserializeOwned>( &self, method: &str, params: &P, context: &RequestContext, ) -> RpcResult<R>

Call one advertised method on the client and await its response.

The deadline and cancellation come from the request being served, so an abandoned caller takes its callback down with it and no answer can arrive for a request that is already terminal.

Trait Implementations§

Source§

impl Clone for Peer

Source§

fn clone(&self) -> Self

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
Source§

impl Debug for Peer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Peer

§

impl !UnwindSafe for Peer

§

impl Freeze for Peer

§

impl Send for Peer

§

impl Sync for Peer

§

impl Unpin for Peer

§

impl UnsafeUnpin for Peer

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.