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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use std::io;
use futures::{Stream, Poll, Async};
use tokio_proto::streaming::Body;
#[derive(Debug)]
pub struct ResponseStream {
pub inner: Body<Message, io::Error>,
}
impl Stream for ResponseStream {
type Item = Message;
type Error = io::Error;
fn poll(&mut self) -> Poll<Option<Message>, io::Error> {
match self.inner.poll().unwrap() {
Async::Ready(Some(request)) => {
Ok(Async::Ready(Some(request)))
}
Async::Ready(None) => {
Ok(Async::Ready(None))
}
Async::NotReady => {
Ok(Async::NotReady)
}
}
}
}
pub struct Message {
pub timestamp: i64,
pub message_id: String,
pub message_body: String
}