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

Issue:
error: the trait bound `websocket::ws::Message` is not satisfied
Hello, perhaps I'm using the library incorrectly, but I cannot figure out how to use `Client::recv_message` properly. I'm getting the following error message:

```
error[E0277]: the trait bound `websocket::Message<'_>: websocket::ws::Message<'_, websocket::DataFrame>` is not satisfied
  --> tests/send.rs:21:35
   |
21 |     let message: Message = client.recv_message().unwrap();
   |                                   ^^^^^^^^^^^^ the trait `websocket::ws::Message<'_, websocket::DataFrame>` is not implemented for `websocket::Message<'_>`
   |
   = help: the following implementations were found:
             <websocket::Message<'a> as websocket::ws::Message<'b, &'b websocket::Message<'a>>>
```

I can't find an example of this method being used in the codebase.
error: the trait bound `websocket::ws::Message` is not satisfied
Hello, perhaps I'm using the library incorrectly, but I cannot figure out how to use `Client::recv_message` properly. I'm getting the following error message:

```
error[E0277]: the trait bound `websocket::Message<'_>: websocket::ws::Message<'_, websocket::DataFrame>` is not satisfied
  --> tests/send.rs:21:35
   |
21 |     let message: Message = client.recv_message().unwrap();
   |                                   ^^^^^^^^^^^^ the trait `websocket::ws::Message<'_, websocket::DataFrame>` is not implemented for `websocket::Message<'_>`
   |
   = help: the following implementations were found:
             <websocket::Message<'a> as websocket::ws::Message<'b, &'b websocket::Message<'a>>>
```

I can't find an example of this method being used in the codebase.


Discussion / hints:
@euclio thanks for submitting the issue! Can you give the full example of where you used that code? Thanks!
Simplified example:

```
extern crate websocket;

use websocket::{ClientBuilder, Message};

fn main() {
    let client = ClientBuilder::new("ws://localhost:3000").unwrap().connect_insecure().unwrap();
    client.send_message(&Message::text("Hello world!")).unwrap();
    let message: Message = client.recv_message().unwrap();
}
```
@euclio yes you're right this is a real bug. I'll work on a fix soon.
in the mean time `.incoming_messages` works correctly.
@euclio thanks for submitting the issue! Can you give the full example of where you used that code? Thanks!
Simplified example:

```
extern crate websocket;

use websocket::{ClientBuilder, Message};

fn main() {
    let client = ClientBuilder::new("ws://localhost:3000").unwrap().connect_insecure().unwrap();
    client.send_message(&Message::text("Hello world!")).unwrap();
    let message: Message = client.recv_message().unwrap();
}
```
@euclio yes you're right this is a real bug. I'll work on a fix soon.
in the mean time `.incoming_messages` works correctly.

Fix patch:
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 01d83ca033..fe2ce61316 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -162,9 +162,22 @@ impl<S> Client<S>
 	}
 
 	/// Reads a single message from this receiver.
-	pub fn recv_message<'m, M, I>(&mut self) -> WebSocketResult<M>
-		where M: ws::Message<'m, DataFrame, DataFrameIterator = I>,
-		      I: Iterator<Item = DataFrame>
+	///
+	/// ```rust,no_run
+	/// use websocket::{ClientBuilder, Message};
+	/// let mut client = ClientBuilder::new("ws://localhost:3000")
+	///     .unwrap()
+	///     .connect_insecure()
+	///     .unwrap();
+	///
+	/// client.send_message(&Message::text("Hello world!")).unwrap();
+	///
+	/// let message: Message = client.recv_message().unwrap();
+	/// ```
+	pub fn recv_message<'m, M, I, D>(&mut self) -> WebSocketResult<M>
+		where M: ws::Message<'m, D, DataFrameIterator = I>,
+		      I: Iterator<Item = D>,
+		      D: DataFrameable
 	{
 		self.receiver.recv_message(&mut self.stream)
 	}
diff --git a/src/receiver.rs b/src/receiver.rs
index ea3688094f..87ff9f22b9 100644
--- a/src/receiver.rs
+++ b/src/receiver.rs
@@ -39,9 +39,10 @@ impl<R> Reader<R>
 	}
 
 	/// Reads a single message from this receiver.
-	pub fn recv_message<'m, M, I>(&mut self) -> WebSocketResult<M>
-		where M: ws::Message<'m, DataFrame, DataFrameIterator = I>,
-		      I: Iterator<Item = DataFrame>
+	pub fn recv_message<'m, M, D, I>(&mut self) -> WebSocketResult<M>
+		where M: ws::Message<'m, D, DataFrameIterator = I>,
+		      I: Iterator<Item = D>,
+		      D: DataFrameable
 	{
 		self.receiver.recv_message(&mut self.stream)
 	}


Test patch: