core_pb::threaded_websocket

Trait ThreadableSocket

Source
pub trait ThreadableSocket<SendType, ReceiveType>: Sized {
    // Required methods
    async fn my_connect(addr: Address) -> Result<Self, ()>;
    async fn my_send(&mut self, data: TextOrT<Vec<u8>>);
    async fn my_read(&mut self) -> Result<TextOrT<Vec<u8>>, ()>;
    async fn my_close(self);
}
Expand description

Represents a type that is compatible with ThreadedSocket

Required Methods§

Source

async fn my_connect(addr: Address) -> Result<Self, ()>

Try to connect to the address

Do not do any retries, fail as soon as possible

Source

async fn my_send(&mut self, data: TextOrT<Vec<u8>>)

Send the data to the socket

If this is impossible, simply drop the data

Source

async fn my_read(&mut self) -> Result<TextOrT<Vec<u8>>, ()>

Try to read from the socket

If the connection is no longer available, return Err(())

Source

async fn my_close(self)

Close the socket

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<SendType: Serialize, ReceiveType: DeserializeOwned> ThreadableSocket<SendType, ReceiveType> for WebSocketStream<ConnectStream>

Source§

async fn my_connect(addr: Address) -> Result<Self, ()>

Source§

async fn my_send(&mut self, data: TextOrT<Vec<u8>>)

Source§

async fn my_read(&mut self) -> Result<TextOrT<Vec<u8>>, ()>

Source§

async fn my_close(self)

Implementors§

Source§

impl<SendType: Serialize, ReceiveType: DeserializeOwned> ThreadableSocket<SendType, ReceiveType> for TcpStreamThreadableSocket