Repository: websockets-rs/rust-websocket (language: rust)

Issue:
Implement From<String> for OwnedMessage
Hi,
Is there any reason why [OwnedMessage](https://docs.rs/websocket/0.22.0/websocket/message) does not implement `From<String>`? Since it is used as a `SinkItem` of the [async client](https://docs.rs/websocket/0.22.0/websocket/client/async/type.Client.html), I can't use the `Sink` produced by the async client in the following fashion:
```rust
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!


Discussion / hints:
> Is there any reason why OwnedMessage does not implement From<String>?

Probably no. Pull request is welcome.
In that case, should it also implement `From<Vec<u8>>`?
Yes.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index be0089bc90..b4eb3c2556 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,8 +5,8 @@ before_script:
   - export PATH="$PATH:$HOME/.cargo/bin"
 
 install:
-  - rustup component add rustfmt-preview
-  - rustup component add clippy-preview
+  - rustup component add rustfmt
+  - rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
 
 script:
   - cargo fmt -- --version
diff --git a/src/message.rs b/src/message.rs
index 91bf14aa2c..1613833ebf 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -436,6 +436,18 @@ impl ws::dataframe::DataFrame for OwnedMessage {
 	}
 }
 
+impl From<String> for OwnedMessage {
+	fn from(text: String) -> Self {
+		OwnedMessage::Text(text)
+	}
+}
+
+impl From<Vec<u8>> for OwnedMessage {
+	fn from(buf: Vec<u8>) -> Self {
+		OwnedMessage::Binary(buf)
+	}
+}
+
 impl<'m> From<Message<'m>> for OwnedMessage {
 	fn from(message: Message<'m>) -> Self {
 		match message.opcode {


Test patch: