Skip to main content

CrossBridgePeer

Struct CrossBridgePeer 

Source
pub struct CrossBridgePeer<U: BridgePeer + ?Sized> { /* private fields */ }
Expand description

A bridge peer that runs every request and reply through a cross-protocol codec before reaching the inner peer.

Constructed cheaply: the only state is the inner peer’s Arc and the codec. Both are expected to be Send + Sync (the codec is required to be, and the inner peer is a BridgePeer, which already is).

Implementations§

Source§

impl<U: BridgePeer + ?Sized> CrossBridgePeer<U>

Source

pub fn new( downstream_side: ProtocolSide, codec: Arc<dyn CrossProtocolCodec>, inner: Arc<U>, ) -> Result<Self, BridgeError>

A wrapper around inner that translates through codec.

downstream_side is the protocol the downstream leg speaks; the wrapper passes it to every call so the codec knows which direction to drive. A symmetric codec that handles both directions declares one of them in downstream_protocol and lets the bridge pick the other; the bridge’s downstream_side is the source of truth, not the codec’s declaration.

Source

pub const fn downstream_side(&self) -> ProtocolSide

The protocol this peer reports for the downstream leg.

Source

pub fn codec(&self) -> &Arc<dyn CrossProtocolCodec> ⓘ

The codec the wrapper runs envelopes through.

Source

pub const fn inner(&self) -> &Arc<U> ⓘ

The inner upstream peer the codec writes to.

Source

pub fn bridges(&self, ir_method: &str) -> bool

Whether the codec bridges the given IR method.

The bridge loop asks this once at feature-check time, so a method that is not bridged is refused with -32601 before the codec is invoked and the inner peer is contacted. The check is the codec’s wire_method table — the same table the codec uses to translate — so the answer cannot disagree with the codec.

Trait Implementations§

Source§

impl<U: BridgePeer + ?Sized> BridgePeer for CrossBridgePeer<U>

Source§

fn send( &self, envelope: Map<String, Value>, ) -> SendFuture<'_, Result<Map<String, Value>, BridgeError>>

Delivers one envelope and yields the peer’s answer. Read more
Source§

fn notify( &self, envelope: Map<String, Value>, ) -> SendFuture<'_, Result<(), BridgeError>>

Delivers one envelope that expects no answer. Read more
Source§

fn close(&self) -> SendFuture<'_, Result<(), BridgeError>>

Ends the conversation, flushing anything in flight. Read more
Source§

fn listen(&self) -> SendFuture<'_, Result<(), BridgeError>>

Starts delivering frames the peer pushes on its own. Read more
Source§

fn take_pending(&self) -> Vec<Map<String, Value>>

Frames the peer received that are the answer to nothing the bridge asked. Read more
Source§

fn wait_pending(&self) -> SendFuture<'static, ()>

Resolves once the peer may have something for take_pending. Read more
Source§

impl<U: Debug + BridgePeer + ?Sized> Debug for CrossBridgePeer<U>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<U> !RefUnwindSafe for CrossBridgePeer<U>

§

impl<U> !UnwindSafe for CrossBridgePeer<U>

§

impl<U> Freeze for CrossBridgePeer<U>
where Arc<U>: Freeze, U: ?Sized,

§

impl<U> Send for CrossBridgePeer<U>
where Arc<U>: Send, U: ?Sized,

§

impl<U> Sync for CrossBridgePeer<U>
where Arc<U>: Sync, U: ?Sized,

§

impl<U> Unpin for CrossBridgePeer<U>
where Arc<U>: Unpin, U: ?Sized,

§

impl<U> UnsafeUnpin for CrossBridgePeer<U>
where Arc<U>: UnsafeUnpin, U: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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, 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