Skip to content

Provide a simple async fn send method for better interoperability with futures-lite based facilities #142

@stackinspector

Description

@stackinspector

Smol(futures-lite)'s guys think that futures_sink::Sink (till v0.3) is a legacy API and excluded related APIs in futures-lite intentionally. They prefer a simple async fn send API.
Before a new simple Sink API is normalized, I suggest considering implementing a simple async fn send method:

impl<S> WebSocketStream<S> {
    /// Simple send method to replace `futures_sink::Sink` (till v0.3).
    pub async fn send(&mut self, msg: Message) -> Result<(), WsError>
    where
        S: AsyncRead + AsyncWrite + Unpin,
    {
        // Example to make it work. A simpler internal way can be used to implement it.
        SinkExt::send(self, msg).await
    }
}

In an ideal world, the send method would be called even if the SinkExt was introduced. I'm not sure if there would be additional problems if a method name is duplicated with a method in trait.
cc smol-rs/futures-lite#111 smol-rs/futures-lite#112

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions