1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use result::WebSocketResult;
use std::io::Write;
use ws::dataframe::DataFrame;
use ws::Message;
pub trait Sender {
fn is_masked(&self) -> bool;
fn send_dataframe<D, W>(&mut self, writer: &mut W, dataframe: &D) -> WebSocketResult<()>
where
D: DataFrame,
W: Write,
{
dataframe.write_to(writer, self.is_masked())?;
Ok(())
}
fn send_message<M, W>(&mut self, writer: &mut W, message: &M) -> WebSocketResult<()>
where
M: Message,
W: Write,
{
message.serialize(writer, self.is_masked())?;
Ok(())
}
}