pub struct WebSocket { /* private fields */ }

Implementations

Get current websocket connection URL

Changes WebSocket connection URL. Following this call, you must invoke WebSocket::reconnect().await manually

Returns reference to the transmission channel. You can clone the channel and use it directly. The channel sends DispatchMessage struct that has two values:

- DispatchMessage::Post(Message)
- DispatchMessage::WithAck(Message, Sender<Result<Arc<(),Arc<Error>>>)

To use WithAck message, you need to create an instance of oneshot channel and supply the sender, while retain and await on receiver.recv() to get acknowledgement that the message has been successfully handed off to the underlying websocket.

Returns the reference to the receiver channel

Returns true if websocket is connected, false otherwise

Connects the websocket to the destination URL. Optionally accepts block_until_connected argument that will block the async execution until the websocket is connected.

Once invoked, connection task will run in the background and will attempt to repeatedly reconnect if the websocket connection is closed.

To suspend reconnection, you have to call disconnect() method explicitly.

Disconnects the websocket from the destination server.

Trigger WebSocket to reconnect. This method closes the underlying WebSocket connection causing the WebSocket implementation to re-initiate connection.

Sends a message to the destination server. This function will queue the message on the relay channel and return successfully if the message has been queued. This function enforces async yield in order to prevent potential blockage of the executor if it is being executed in tight loops.

Sends a message to the destination server. This function will block until until the message was relayed to the underlying websocket implementation.

Receives message from the websocket. Blocks until a message is received from the underlying websocket connection.

Helper function that will relay a Ctl enum to the receiver in the form of Message::Ctl(Ctl::*) This should be called only with Ctl::Custom(u32) as other control messages are issues by the underlying websocket implementation

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.