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>
impl<T> PeerTransport<T>
Source§impl<T: Transport + Clone + Send + Sync + 'static> PeerTransport<T>
impl<T: Transport + Clone + Send + Sync + 'static> PeerTransport<T>
Sourcepub async fn check(&self, path: &str, stamp: &Stamp) -> Result<(), PeerError>
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.
Sourcepub async fn admit(&self, path: &str, stamp: &Stamp) -> Result<(), PeerError>
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.
Sourcepub async fn guard(
&self,
path: &str,
stamp: &Stamp,
method: &str,
) -> Result<(), PeerError>
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.
Sourcepub async fn after(
&self,
path: &str,
stamp: &Stamp,
method: &str,
) -> Result<(), PeerError>
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.
Sourcepub async fn call_peer(
&self,
path: &str,
method: &str,
params: Value,
known: &Interface,
) -> Result<PlexusStream, PlexusError>
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>
impl<T: Clone> Clone for PeerTransport<T>
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.
impl<T: Transport + Send + Sync> Transport for PeerTransport<T>
Every item a transport yields is watched for its plexus_hash.
fn call(&self, method: MethodRef, params: Value) -> ItemStream<'_>
Source§fn call_raw(&self, method: MethodRef, params: Value) -> RawItemStream<'_>
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>>
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>>
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>>
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>>
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.