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
use codec;
use futures::{stream, Stream};
use std::io;
use tokio_core::io::{Io, Framed};
use tokio_proto::pipeline::ServerProto;
use types::{GopherRequest, GopherResponse};
pub struct GopherServer;
impl<T: Io + 'static> ServerProto<T> for GopherServer {
type Request = GopherRequest;
type Response = GopherResponse;
type Transport = stream::Take<Framed<T, codec::Server>>;
type BindTransport = Result<Self::Transport, io::Error>;
fn bind_transport(&self, io: T) -> Self::BindTransport {
Ok(io.framed(codec::Server).take(1))
}
}