IrcCodec is no longer paramterized by inner codec type.
This commit is contained in:
parent
a6303d4858
commit
1f3b3d64b5
1 changed files with 6 additions and 13 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue