Skip to main content

Module contract

Module contract 

Source
Expand description

MACRO-13 · what a trait the activation macro emits leans on.

#[plexus_macros::activation(trait)] on impl FooActivation emits trait Foo: every wire method as fn(&self, ..) -> BoxStream<'static, E>, implemented by the activation and by FooClient<T>. A client call is a stream of Result<E, ClientError> (RETURNS-9’s MethodStream, progress already dropped); a trait method is a stream of E. This module is the bridge:

  • FromClientError — how a client failure becomes the event type’s own in-band error (one line, usually Error { message }), so a caller of dyn Foo sees one shape whether it is talking to a local implementation or a remote one;
  • owned_call — a 'static call from an owned transport, since a trait method’s stream outlives the &self it was called on;
  • into_events / error_events — the mapping itself: an item is yielded, an error is yielded as E::from_client_error(err) and ends the stream.

RETURNS-36: the trait is always emitted, each method under its own return type: a one-item method’s is a BoxFuture of its item, a stream form’s a BoxStream of its items. trait_one, trait_many, trait_progress and trait_result_progress are the client half’s.

Traits§

FromClientError
An event type that can carry a client failure in band.
MaybeSend
Send off wasm32, nothing on it: the bound a trait’s client half puts on what it moves into a boxed future or stream.

Functions§

error_events
A trait method’s stream that yields E::from_client_error(error) and ends — what an emitted client method returns when a parameter would not serialize.
into_events
A typed client stream as a trait method’s stream: data events yielded, progress dropped, the first error yielded as E::from_client_error(err) and the stream ended there.
owned_call
Transport::call on a transport the stream owns, so the stream is 'static: a trait method returns a stream that outlives the &self it was called on, and Transport::call borrows its transport.
owned_call_raw
owned_call for a typed client: Transport::call_raw on a transport the stream owns (PERF.115-36).
owned_call_raw_with_input
BIDIR-6: owned_call_raw, for a method with an input half.
trait_many
-> impl Stream<Item = T> / Item = Result<T, E>: many items.
trait_one
-> T / -> Result<T, E>: one item.
trait_one_with_input
BIDIR-6: trait_one, for a method with an input half.
trait_progress
-> impl Stream<Item = Progress<T, P>>: items and progress updates.
trait_result_progress
-> impl Stream<Item = Result<Progress<T, P>, E>>.

Type Aliases§

BoxFuture
A boxed future of T — what a one-item method of an emitted trait returns (RETURNS-36). Send off wasm32, as BoxStream is.
BoxStream
A boxed stream of T — the return type of every method of a trait the activation macro emits. Send off wasm32, as ItemStream is; on wasm32 the browser’s futures are !Send, so the bound is dropped.