pub struct HttpTransport<R, W> { /* private fields */ }Expand description
HTTP transport for stateless MCP communication.
In stateless mode, each HTTP request contains a single JSON-RPC message and receives a single response. This is suitable for simple integrations where session state is not needed.
Implementations§
Source§impl<R, W> HttpTransport<R, W>
impl<R, W> HttpTransport<R, W>
Sourcepub fn new(reader: R, writer: W) -> HttpTransport<R, W>
pub fn new(reader: R, writer: W) -> HttpTransport<R, W>
Creates a new HTTP transport.
Sourcepub fn read_request(&mut self) -> Result<HttpRequest, HttpError>
pub fn read_request(&mut self) -> Result<HttpRequest, HttpError>
Reads an HTTP request from the reader.
Sourcepub fn write_response(
&mut self,
response: &HttpResponse,
) -> Result<(), HttpError>
pub fn write_response( &mut self, response: &HttpResponse, ) -> Result<(), HttpError>
Writes an HTTP response to the writer.
Sourcepub fn queue_response(&mut self, response: JsonRpcResponse)
pub fn queue_response(&mut self, response: JsonRpcResponse)
Queues a response to be sent.
Trait Implementations§
Source§impl<R, W> Transport for HttpTransport<R, W>
impl<R, W> Transport for HttpTransport<R, W>
Source§fn send(
&mut self,
cx: &Cx,
message: &JsonRpcMessage,
) -> Result<(), TransportError>
fn send( &mut self, cx: &Cx, message: &JsonRpcMessage, ) -> Result<(), TransportError>
Send a JSON-RPC message through this transport. Read more
Source§fn recv(&mut self, cx: &Cx) -> Result<JsonRpcMessage, TransportError>
fn recv(&mut self, cx: &Cx) -> Result<JsonRpcMessage, TransportError>
Receive the next JSON-RPC message from this transport. Read more
Source§fn send_request(
&mut self,
cx: &Cx,
request: &JsonRpcRequest,
) -> Result<(), TransportError>
fn send_request( &mut self, cx: &Cx, request: &JsonRpcRequest, ) -> Result<(), TransportError>
Send a request through this transport. Read more
Source§fn send_response(
&mut self,
cx: &Cx,
response: &JsonRpcResponse,
) -> Result<(), TransportError>
fn send_response( &mut self, cx: &Cx, response: &JsonRpcResponse, ) -> Result<(), TransportError>
Send a response through this transport. Read more
Auto Trait Implementations§
impl<R, W> Freeze for HttpTransport<R, W>
impl<R, W> RefUnwindSafe for HttpTransport<R, W>where
R: RefUnwindSafe,
W: RefUnwindSafe,
impl<R, W> Send for HttpTransport<R, W>
impl<R, W> Sync for HttpTransport<R, W>
impl<R, W> Unpin for HttpTransport<R, W>
impl<R, W> UnwindSafe for HttpTransport<R, W>where
R: UnwindSafe,
W: UnwindSafe,
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).