Skip to main content

PeerTransport

Struct PeerTransport 

Source
pub struct PeerTransport<T> { /* private fields */ }
Expand description

A transport for a contract’s client that checks the backend against the client’s Stamp: the backend’s interface is asked once (and again when an item’s plexus_hash moves); every item is watched for that.

Implementations§

Source§

impl<T> PeerTransport<T>

Source

pub fn new(inner: T) -> Self

Source

pub fn inner(&self) -> &T

Source

pub fn interface(&self) -> Option<Interface>

The backend’s interface as last checked.

Source

pub fn drift(&self) -> Option<Drift>

The drift said, if the backend moved within the stamp.

Source

pub fn checks(&self) -> usize

How many times the backend’s interface was asked.

Source

pub fn drifts_said(&self) -> usize

How many times drift was said (at most once per change).

Source§

impl<T: Transport + Clone + Send + Sync + 'static> PeerTransport<T>

Source

pub async fn check(&self, path: &str, stamp: &Stamp) -> Result<(), PeerError>

Ask the backend’s interface at path (its schema) and check it against stamp: equal → go; it serves every method of the stamp under the same hash → go, saying drift once; else the methods that moved are kept, and Self::admit refuses them all, a call only its own.

Source

pub async fn admit(&self, path: &str, stamp: &Stamp) -> Result<(), PeerError>

Becoming a peer: check, and refuse a backend any of the stamp’s methods moved on.

Source

pub async fn guard( &self, path: &str, stamp: &Stamp, method: &str, ) -> Result<(), PeerError>

Before a call of method: check when never checked or when an item’s plexus_hash moved; refuse the call when its own method moved.

Source

pub async fn after( &self, path: &str, stamp: &Stamp, method: &str, ) -> Result<(), PeerError>

After a call of method: when its items’ plexus_hash moved, ask again once — and fail this call if its own method moved.

Source

pub async fn call_peer( &self, path: &str, method: &str, params: Value, known: &Interface, ) -> Result<PlexusStream, PlexusError>

A peer’s call through the client’s transport: method (repos, or a path below the contract) at path, its items as the service’s. Only a method the interface names is called (a name from a caller is never interned otherwise).

Trait Implementations§

Source§

impl<T: Clone> Clone for PeerTransport<T>

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<T: Transport + Send + Sync> Transport for PeerTransport<T>

Available on non-WebAssembly only.

Every item a transport yields is watched for its plexus_hash.

Source§

fn call(&self, method: MethodRef, params: Value) -> ItemStream<'_>

Source§

fn call_raw(&self, method: MethodRef, params: Value) -> RawItemStream<'_>

call for a typed client (PERF.115-36): the same items, each data item’s content still the wire’s JSON, which decode_raw decodes straight into the method’s event. The default is call’s items, each content the Value it carries; a transport that has the wire’s text (WsTransport) hands it over unread.
Source§

fn call_with_input<'a>( &'a self, method: MethodRef, params: Value, input: Pin<Box<dyn Stream<Item = Result<InputItem, TransportError>> + Send + 'a>>, ) -> Pin<Box<dyn Stream<Item = Result<StreamItem, TransportError>> + Send + 'a>>

BIDIR-6: call, for a method with an input half: input is sent as the call runs, under the callee’s credit, and ended when it ends. A transport that carries no input half (the default) says so in the one item it yields: the call does not hang.
Source§

fn call_raw_with_input<'a>( &'a self, method: MethodRef, params: Value, input: Pin<Box<dyn Stream<Item = Result<InputItem, TransportError>> + Send + 'a>>, ) -> Pin<Box<dyn Stream<Item = Result<RawItem, TransportError>> + Send + 'a>>

BIDIR-6: call_raw, for a method with an input half: what a typed client’s method with an Input calls. The default is call_with_input’s items, each content the Value it carries.

Auto Trait Implementations§

§

impl<T> Forget for PeerTransport<T>

§

impl<T> Freeze for PeerTransport<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PeerTransport<T>
where T: RefUnwindSafe,

§

impl<T> Send for PeerTransport<T>
where T: Send,

§

impl<T> Sync for PeerTransport<T>
where T: Sync,

§

impl<T> Unpin for PeerTransport<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for PeerTransport<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for PeerTransport<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more