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>
impl<U: BridgePeer + ?Sized> CrossBridgePeer<U>
Sourcepub fn new(
downstream_side: ProtocolSide,
codec: Arc<dyn CrossProtocolCodec>,
inner: Arc<U>,
) -> Result<Self, BridgeError>
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.
Sourcepub const fn downstream_side(&self) -> ProtocolSide
pub const fn downstream_side(&self) -> ProtocolSide
The protocol this peer reports for the downstream leg.
Sourcepub fn codec(&self) -> &Arc<dyn CrossProtocolCodec> ⓘ
pub fn codec(&self) -> &Arc<dyn CrossProtocolCodec> ⓘ
The codec the wrapper runs envelopes through.
Sourcepub fn bridges(&self, ir_method: &str) -> bool
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>
impl<U: BridgePeer + ?Sized> BridgePeer for CrossBridgePeer<U>
Source§fn send(
&self,
envelope: Map<String, Value>,
) -> SendFuture<'_, Result<Map<String, Value>, BridgeError>>
fn send( &self, envelope: Map<String, Value>, ) -> SendFuture<'_, Result<Map<String, Value>, BridgeError>>
Source§fn notify(
&self,
envelope: Map<String, Value>,
) -> SendFuture<'_, Result<(), BridgeError>>
fn notify( &self, envelope: Map<String, Value>, ) -> SendFuture<'_, Result<(), BridgeError>>
Source§fn close(&self) -> SendFuture<'_, Result<(), BridgeError>>
fn close(&self) -> SendFuture<'_, Result<(), BridgeError>>
Source§fn listen(&self) -> SendFuture<'_, Result<(), BridgeError>>
fn listen(&self) -> SendFuture<'_, Result<(), BridgeError>>
Source§fn take_pending(&self) -> Vec<Map<String, Value>>
fn take_pending(&self) -> Vec<Map<String, Value>>
Source§fn wait_pending(&self) -> SendFuture<'static, ()>
fn wait_pending(&self) -> SendFuture<'static, ()>
take_pending. Read more