IrcCodec is no longer paramterized by inner codec type.

This commit is contained in:
Aaron Weiss 2017-01-15 17:06:43 -05:00
parent a6303d4858
commit 1f3b3d64b5
No known key found for this signature in database
GPG key ID: 0237035D9BF03AE2

View file

@ -6,25 +6,18 @@ use proto::message::Message;
use tokio_core::io::{Codec, EasyBuf}; use tokio_core::io::{Codec, EasyBuf};
/// An IRC codec built around an inner codec. /// An IRC codec built around an inner codec.
pub struct IrcCodec<C: Codec> { pub struct IrcCodec {
inner: C, inner: LineCodec,
} }
impl IrcCodec<LineCodec> { impl IrcCodec {
/// Creates a new instance of IrcCodec wrapping a LineCodec with the specifiec encoding. /// Creates a new instance of IrcCodec wrapping a LineCodec with the specifiec encoding.
pub fn new(label: &str) -> io::Result<IrcCodec<LineCodec>> { pub fn new(label: &str) -> io::Result<IrcCodec> {
LineCodec::new(label).map(|codec| IrcCodec::from_codec(codec)) LineCodec::new(label).map(|codec| IrcCodec { inner: codec })
} }
} }
impl<C> IrcCodec<C> where C: Codec<In = String, Out = String> { impl Codec for IrcCodec {
/// Creates a new instance of IrcCodec from the specified inner codec.
pub fn from_codec(codec: C) -> IrcCodec<C> {
IrcCodec { inner: codec }
}
}
impl<C> Codec for IrcCodec<C> where C: Codec<In = String, Out = String> {
type In = Message; type In = Message;
type Out = Message; type Out = Message;