pub struct WebSocketClientTransport { /* private fields */ }Expand description
A WebSocket client transport for MCP backend connections.
Connects to a WebSocket endpoint and exchanges JSON-RPC messages
as text frames. Supports ws:// and wss:// (TLS) URLs.
Implementations§
Source§impl WebSocketClientTransport
impl WebSocketClientTransport
Sourcepub async fn connect(url: &str) -> Result<Self>
pub async fn connect(url: &str) -> Result<Self>
Connect to a WebSocket endpoint.
§Errors
Returns an error if the WebSocket handshake fails or the URL is invalid.
Sourcepub async fn connect_with_bearer_token(url: &str, token: &str) -> Result<Self>
pub async fn connect_with_bearer_token(url: &str, token: &str) -> Result<Self>
Connect to a WebSocket endpoint with a bearer token for authentication.
The token is sent in the Authorization header during the handshake.
Trait Implementations§
Source§impl ClientTransport for WebSocketClientTransport
impl ClientTransport for WebSocketClientTransport
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a raw JSON message to the server. Read more
Source§fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive the next raw JSON message from the server. Read more
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the transport is still connected.
Auto Trait Implementations§
impl Freeze for WebSocketClientTransport
impl !RefUnwindSafe for WebSocketClientTransport
impl Send for WebSocketClientTransport
impl Sync for WebSocketClientTransport
impl Unpin for WebSocketClientTransport
impl UnsafeUnpin for WebSocketClientTransport
impl !UnwindSafe for WebSocketClientTransport
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
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>
Converts
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>
Converts
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