Trait graphql_ws_client::Connection

source ·
pub trait Connection {
    // Required methods
    fn receive(&mut self) -> impl Future<Output = Option<Message>> + Send;
    fn send(
        &mut self,
        message: Message,
    ) -> impl Future<Output = Result<(), Error>> + Send;
}
Expand description

Abstrction around a websocket connection.

Built in implementations are provided for ws_stream_wasm & async_tungstenite.

If users wish to add support for a new client they should implement this trait.

Required Methods§

source

fn receive(&mut self) -> impl Future<Output = Option<Message>> + Send

Receive the next message on this connection.

source

fn send( &mut self, message: Message, ) -> impl Future<Output = Result<(), Error>> + Send

Send a message with on connection

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Connection for Connection

Available on crate feature ws_stream_wasm only.
source§

impl<T> Connection for T
where T: Stream<Item = Result<Message, Error>> + Sink<Message> + Send + Sync + Unpin, <T as Sink<Message>>::Error: Display,

Available on crate feature tungstenite only.