websockets-rs / rust-websocket

A WebSocket (RFC6455) library written in Rust

Home Page:http://websockets-rs.github.io/rust-websocket/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement From<String> for OwnedMessage

jean-airoldie opened this issue · comments

Hi,
Is there any reason why OwnedMessage does not implement From<String>? Since it is used as a SinkItem of the async client, I can't use the Sink produced by the async client in the following fashion:

pub fn foo<S: Sink>(sink: &mut S)
where
    <S as Sink>::SinkItem: From<String>,
    <S as Sink>::SinkError: Debug,
{
    let text = "ok".to_string();
    sink.start_send(text.into()).unwrap();
}

In the current configuration, I am forced to define my own intermediary type which implements From<String> and Into<OwnedMessage>.

Thanks!

Is there any reason why OwnedMessage does not implement From?

Probably no. Pull request is welcome.

In that case, should it also implement From<Vec<u8>>?