Skip to main content

EventStreamTransport

Trait EventStreamTransport 

Source
pub trait EventStreamTransport {
    // Required method
    fn open_event_stream<'life0, 'async_trait>(
        &'life0 self,
        body: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<SubscriptionFrameStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Available on crate feature streamable-http and non-WebAssembly only.
Expand description

A transport that can open a long-lived server-push stream.

Deliberately a SEPARATE trait rather than another defaulted method on Transport: an incrementally-read response body is an HTTP concept, and every stdio / WebSocket / wasm transport would have to carry a meaningless default for it. Keeping it separate also means Client::subscriptions_listen is generic — a test stub can implement this trait and observe that a non-v2 client never opens a stream at all.

Required Methods§

Source

fn open_event_stream<'life0, 'async_trait>( &'life0 self, body: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<SubscriptionFrameStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

POST body and return its response body as a stream of SSE payloads.

§Errors

Returns the server’s own JSON-RPC error (e.g. -32601 from a server that advertises no subscription-delivered capability) when the response is a JSON document rather than a text/event-stream, and a transport error when the request could not be made.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§