Trait WebsocketMessage

Source
pub trait WebsocketMessage: Debug {
    type Error: Error + Send + 'static;

    // Required methods
    fn new(text: String) -> Self;
    fn text(&self) -> Option<&str>;
    fn error_message(&self) -> Option<String>;
    fn is_ping(&self) -> bool;
    fn is_pong(&self) -> bool;
    fn is_close(&self) -> bool;
}
Expand description

An abstraction around WebsocketMessages

graphql-ws-client doesn’t implement the websocket protocol itself. This trait provides part of the integration with websocket client libraries.

Required Associated Types§

Source

type Error: Error + Send + 'static

The Error type for this websocket client.

Required Methods§

Source

fn new(text: String) -> Self

Constructs a new message with the given text

Source

fn text(&self) -> Option<&str>

Returns the text (if there is any) contained in this message

Source

fn error_message(&self) -> Option<String>

Returns the text (if there is any) of the error

Source

fn is_ping(&self) -> bool

Returns true if this message is a websocket ping.

Source

fn is_pong(&self) -> bool

Returns true if this message is a websocket pong.

Source

fn is_close(&self) -> bool

Returns true if this message is a websocket close.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl WebsocketMessage for Message

Source§

type Error = Error

Source§

fn new(text: String) -> Self

Source§

fn text(&self) -> Option<&str>

Source§

fn error_message(&self) -> Option<String>

Source§

fn is_ping(&self) -> bool

Source§

fn is_pong(&self) -> bool

Source§

fn is_close(&self) -> bool

Implementors§