Removed dependence on tokio-proto.

This commit is contained in:
Aaron Weiss 2017-01-15 17:02:37 -05:00
parent 843b7ba3c0
commit a6303d4858
No known key found for this signature in database
GPG key ID: 0237035D9BF03AE2
3 changed files with 2 additions and 41 deletions

View file

@ -21,5 +21,4 @@ rustc-serialize = "0.3.0"
time = "0.1.0"
encoding = "0.2.0"
tokio-core = "0.1.3"
tokio-proto = "0.1.0"
tokio-service = "0.1.0"

View file

@ -6,7 +6,6 @@ extern crate time;
extern crate encoding;
extern crate rustc_serialize;
extern crate tokio_core;
extern crate tokio_proto;
extern crate tokio_service;
pub mod client;

View file

@ -1,10 +1,9 @@
//! Implementation of IRC protocol for Tokio.
//! Implementation of IRC codec for Tokio.
use std::io;
use proto::line::LineCodec;
use proto::message::Message;
use tokio_core::io::{Codec, EasyBuf, Framed, Io};
use tokio_proto::pipeline::{ServerProto, ClientProto};
use tokio_core::io::{Codec, EasyBuf};
/// An IRC codec built around an inner codec.
pub struct IrcCodec<C: Codec> {
@ -41,39 +40,3 @@ impl<C> Codec for IrcCodec<C> where C: Codec<In = String, Out = String> {
self.inner.encode(msg.to_string(), buf)
}
}
/// Implementation of the IRC protocol backed by a line-delimited codec.
pub struct IrcProto {
encoding_label: String,
}
impl IrcProto {
/// Creates a new IrcProto using the specified WHATWG encoding label.
fn new(label: &str) -> IrcProto {
IrcProto { encoding_label: label.to_owned() }
}
}
impl<T> ClientProto<T> for IrcProto where T: Io + 'static {
type Request = Message;
type Response = Message;
type Transport = Framed<T, IrcCodec<LineCodec>>;
type BindTransport = Result<Self::Transport, io::Error>;
fn bind_transport(&self, io: T) -> Self::BindTransport {
Ok(io.framed(try!(IrcCodec::new(&self.encoding_label))))
}
}
impl<T> ServerProto<T> for IrcProto where T: Io + 'static {
type Request = Message;
type Response = Message;
type Transport = Framed<T, IrcCodec<LineCodec>>;
type BindTransport = Result<Self::Transport, io::Error>;
fn bind_transport(&self, io: T) -> Self::BindTransport {
Ok(io.framed(try!(IrcCodec::new(&self.encoding_label))))
}
}