pub struct RpcOutbound { /* private fields */ }Expand description
Writer + outbound-call tracker shared between server loops and per-session bridges (e.g. AcpChannel, RpcDispatcher).
All writes go through writer_tx so concurrent notifications and
outbound requests cannot interleave bytes. Outbound requests get string
ids (zc-out-<n>) disjoint from any client-issued id space.
Implementations§
Source§impl RpcOutbound
impl RpcOutbound
pub fn new(writer_tx: Sender<String>) -> Self
Sourcepub async fn send_raw(&self, json: String) -> bool
pub async fn send_raw(&self, json: String) -> bool
Send a raw pre-serialized JSON line. Returns true on success.
Sourcepub async fn closed(&self)
pub async fn closed(&self)
Resolve when the writer end is closed (peer dropped). Useful for long-lived forwarders that need to exit on disconnect even when there is no payload to send.
Sourcepub async fn notify(&self, method: &'static str, params: Value)
pub async fn notify(&self, method: &'static str, params: Value)
Send a JSON-RPC notification (no id, no response expected).
Sourcepub async fn request(
&self,
method: &str,
params: Value,
) -> Result<Value, JsonRpcError>
pub async fn request( &self, method: &str, params: Value, ) -> Result<Value, JsonRpcError>
Send a JSON-RPC request and await the response.
Sourcepub fn dispatch_response(
&self,
id_str: &str,
result: Option<Value>,
error: Option<JsonRpcError>,
)
pub fn dispatch_response( &self, id_str: &str, result: Option<Value>, error: Option<JsonRpcError>, )
Route an inbound JSON-RPC response to its pending caller.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of in-flight outbound requests awaiting responses.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RpcOutbound
impl RefUnwindSafe for RpcOutbound
impl Send for RpcOutbound
impl Sync for RpcOutbound
impl Unpin for RpcOutbound
impl UnsafeUnpin for RpcOutbound
impl UnwindSafe for RpcOutbound
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more