pub struct WsRpc<P: Protocol> { /* private fields */ }Expand description
Shared JSON-RPC-over-WebSocket transport. Owns the socket, the reader and
writer tasks (and their JoinHandles), the pending-request correlation
map, the id counter, and the event broadcast channel.
Implementations§
Source§impl<P: Protocol> WsRpc<P>
impl<P: Protocol> WsRpc<P>
Sourcepub async fn connect(ws_url: &str, label: &str) -> Result<Self>
pub async fn connect(ws_url: &str, label: &str) -> Result<Self>
Connect by full WebSocket URL (ws:// or wss://) and spawn the reader and
writer tasks. label is used only in the connect-timeout error message
(e.g. "CDP" / "BiDi").
Sourcepub async fn request(
&self,
method: &str,
params: Value,
session_id: Option<&str>,
) -> Result<Value, RequestError<P::ProtoError>>
pub async fn request( &self, method: &str, params: Value, session_id: Option<&str>, ) -> Result<Value, RequestError<P::ProtoError>>
Send a request and await its correlated reply, bounded by
REQUEST_TIMEOUT. On writer-channel failure the pending entry is
removed before returning (no leak); on timeout it is likewise removed.
A protocol error reply comes back as RequestError::Protocol;
transport faults (writer closed / channel dropped / serialization) as
RequestError::Transport; a no-reply timeout as
RequestError::Timeout.
Callers map these through their own classifier so the protocol-specific
typing stays in crate::cdp / crate::bidi.
Trait Implementations§
Auto Trait Implementations§
impl<P> !Freeze for WsRpc<P>
impl<P> !RefUnwindSafe for WsRpc<P>
impl<P> !UnwindSafe for WsRpc<P>
impl<P> Send for WsRpc<P>
impl<P> Sync for WsRpc<P>
impl<P> Unpin for WsRpc<P>
impl<P> UnsafeUnpin for WsRpc<P>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more