pub struct WebSocketTransport { /* private fields */ }Expand description
WebSocket transport: JSON-RPC 2.0 over a persistent WebSocket connection.
Create via WebSocketTransport::connect and pass to
crate::ClientBuilder::with_custom_transport.
FIX(C2): Uses a dedicated reader task with message routing instead of a shared Mutex on the reader half. This prevents deadlocks when streaming responses are received concurrently with unary requests.
Implementations§
Source§impl WebSocketTransport
impl WebSocketTransport
Sourcepub async fn connect(endpoint: impl Into<String>) -> ClientResult<Self>
pub async fn connect(endpoint: impl Into<String>) -> ClientResult<Self>
Connects to the agent’s WebSocket endpoint.
The endpoint should use the ws:// or wss:// scheme.
§Errors
Returns ClientError::Transport if the WebSocket handshake fails.
Sourcepub async fn connect_with_timeout(
endpoint: impl Into<String>,
request_timeout: Duration,
) -> ClientResult<Self>
pub async fn connect_with_timeout( endpoint: impl Into<String>, request_timeout: Duration, ) -> ClientResult<Self>
Connects with a custom request timeout.
§Errors
Returns ClientError::Transport if the WebSocket handshake fails.
Sourcepub async fn connect_with_options(
endpoint: impl Into<String>,
request_timeout: Duration,
extra_headers: &HashMap<String, String>,
) -> ClientResult<Self>
pub async fn connect_with_options( endpoint: impl Into<String>, request_timeout: Duration, extra_headers: &HashMap<String, String>, ) -> ClientResult<Self>
Connects with a custom request timeout and extra HTTP headers for the initial WebSocket upgrade request.
FIX(C3): Extra headers (e.g. from AuthInterceptor) are applied to the
HTTP upgrade request that establishes the WebSocket connection via the
tungstenite IntoClientRequest trait.
§Errors
Returns ClientError::Transport if the WebSocket handshake fails.
Trait Implementations§
Source§impl Debug for WebSocketTransport
impl Debug for WebSocketTransport
Source§impl Transport for WebSocketTransport
impl Transport for WebSocketTransport
Source§fn send_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = ClientResult<Value>> + Send + 'a>>
fn send_request<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = ClientResult<Value>> + Send + 'a>>
Source§fn send_streaming_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = ClientResult<EventStream>> + Send + 'a>>
fn send_streaming_request<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = ClientResult<EventStream>> + Send + 'a>>
EventStream. Read moreAuto Trait Implementations§
impl Freeze for WebSocketTransport
impl RefUnwindSafe for WebSocketTransport
impl Send for WebSocketTransport
impl Sync for WebSocketTransport
impl Unpin for WebSocketTransport
impl UnsafeUnpin for WebSocketTransport
impl UnwindSafe for WebSocketTransport
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request