From 8e2f17b9838d60214f007c8108ee7069c458f40d Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Wed, 13 Jan 2016 13:32:46 +0100 Subject: Updated dependencies, still doesn't build --- src/format/binary.rs | 4 ++-- src/format/energymech.rs | 15 +++++++-------- src/format/mod.rs | 47 +++++++++++++++++++++-------------------------- src/format/msgpack.rs | 3 ++- src/format/weechat3.rs | 15 +++++++-------- 5 files changed, 39 insertions(+), 45 deletions(-) (limited to 'src/format') diff --git a/src/format/binary.rs b/src/format/binary.rs index a1ca12d..367cdf9 100644 --- a/src/format/binary.rs +++ b/src/format/binary.rs @@ -32,14 +32,14 @@ pub struct Iter<'a, R: 'a> where R: BufRead { impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { type Item = ::Result>; fn next(&mut self) -> Option<::Result>> { - Some(bincode::decode_from::(&mut self.input, SizeLimit::Infinite) + Some(bincode::rustc_serialize::decode_from::(&mut self.input, SizeLimit::Infinite) .map_err(|_| ::IlcError::BincodeDecode)) } } impl<'a, W> Encode<'a, W> for Binary where W: Write { fn encode(&'a self, _context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> { - bincode::encode_into(event, &mut output, SizeLimit::Infinite) + bincode::rustc_serialize::encode_into(event, &mut output, SizeLimit::Infinite) .map_err(|_| ::IlcError::BincodeEncode) } } diff --git a/src/format/energymech.rs b/src/format/energymech.rs index df48318..5965dfa 100644 --- a/src/format/energymech.rs +++ b/src/format/energymech.rs @@ -28,13 +28,13 @@ pub struct Energymech; static TIME_FORMAT: &'static str = "%H:%M:%S"; -pub struct Iter<'a, R: 'a> where R: BufRead { +pub struct Iter<'a> { context: &'a Context, - input: R, + input: &'a mut BufRead, buffer: Vec } -impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { +impl<'a> Iterator for Iter<'a> { type Item = ::Result>; fn next(&mut self) -> Option<::Result>> { fn parse_time(context: &Context, time: &str) -> Time { @@ -153,14 +153,13 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { } } -impl<'a, R: 'a> Decode<'a, R> for Energymech where R: BufRead { - type Output = Iter<'a, R>; - fn decode(&'a mut self, context: &'a Context, input: R) -> Iter { - Iter { +impl<'a> Decode<'a> for Energymech { + fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { + Box::new(Iter { context: context, input: input, buffer: Vec::new() - } + }) } } diff --git a/src/format/mod.rs b/src/format/mod.rs index f918287..4f8eaa1 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -16,55 +16,50 @@ //! As the source format may not provide the same information as the //! target format, all formats must allow for omittable information. +use std::iter; use std::io::{ BufRead, Write }; use std::borrow::Cow; use event::Event; use context::Context; -pub mod weechat3; -pub mod energymech; -pub mod binary; -pub mod msgpack; +//pub mod weechat3; +//pub mod energymech; +//pub mod binary; +//pub mod msgpack; pub trait Encode<'a, W> where W: Write { fn encode(&'a self, context: &'a Context, output: W, event: &'a Event) -> ::Result<()>; } -pub trait Decode<'a, Input> where Input: BufRead, - Self::Output: Iterator>> + 'a { - type Output; - fn decode(&'a mut self, context: &'a Context, input: Input) -> Self::Output; +pub trait Decode<'a, 'b, 'c> { + fn decode(&'a mut self, context: &'b Context, input: &'c mut BufRead) -> Box>> + 'a>; } -pub trait DecodeBox<'a, I> { - fn decode_box(&'a mut self, context: &'a Context, input: I) - -> Box> + 'a>; -} +pub struct Dummy; -impl<'a, T, I: BufRead> DecodeBox<'a, I> for T where T: Decode<'a, I> { - fn decode_box(&'a mut self, context: &'a Context, input: I) - -> Box> + 'a> { - Box::new(self.decode(context, input)) +impl <'a, 'b, 'c> Decode<'a, 'b, 'c> for Dummy { + fn decode(&'a mut self, _context: &'b Context, _input: &'c mut BufRead) -> Box>> + 'a> { + Box::new(iter::empty()) } } -pub fn decoder<'a>(format: &str) -> Option>> { +pub fn decoder<'a, 'b, 'c>(format: &str) -> Option>> { match format { - "energymech" => Some(Box::new(energymech::Energymech)), - "weechat3" => Some(Box::new(weechat3::Weechat3)), - "binary" => Some(Box::new(binary::Binary)), - "msgpack" => Some(Box::new(msgpack::Msgpack)), +// "energymech" => Some(Box::new(energymech::Energymech)), +// "weechat3" => Some(Box::new(weechat3::Weechat3)), +// "binary" => Some(Box::new(binary::Binary)), +// "msgpack" => Some(Box::new(msgpack::Msgpack)), _ => None } } -pub fn encoder<'a>(format: &str) -> Option>> { +pub fn encoder<'a, 'b: 'a>(format: &str) -> Option>> { match format { - "energymech" => Some(Box::new(energymech::Energymech)), - "weechat3" => Some(Box::new(weechat3::Weechat3)), - "binary" => Some(Box::new(binary::Binary)), - "msgpack" => Some(Box::new(msgpack::Msgpack)), +// "energymech" => Some(Box::new(energymech::Energymech)), +// "weechat3" => Some(Box::new(weechat3::Weechat3)), +// "binary" => Some(Box::new(binary::Binary)), +// "msgpack" => Some(Box::new(msgpack::Msgpack)), _ => None } } diff --git a/src/format/msgpack.rs b/src/format/msgpack.rs index 09bd2bb..fb71b99 100644 --- a/src/format/msgpack.rs +++ b/src/format/msgpack.rs @@ -22,6 +22,7 @@ use format::{ Encode, Decode }; use rustc_serialize::{ Encodable, Decodable }; use msgpack::{ Encoder, Decoder }; +use rmp::decode::ReadError; pub struct Msgpack; @@ -36,7 +37,7 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { use msgpack::decode; match Event::decode(&mut Decoder::new(&mut self.input)) { Ok(e) => Some(Ok(e)), - Err(decode::serialize::Error::InvalidMarkerRead(decode::ReadError::UnexpectedEOF)) => None, + Err(decode::Error::InvalidMarkerRead(ReadError::UnexpectedEOF)) => None, Err(e) => Some(Err(::IlcError::MsgpackDecode(e))) } } diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index e733a38..118bd3b 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -26,13 +26,13 @@ pub struct Weechat3; static TIME_DATE_FORMAT: &'static str = "%Y-%m-%d %H:%M:%S"; -pub struct Iter<'a, R: 'a> where R: BufRead { +pub struct Iter<'a> { context: &'a Context, - input: R, + input: &'a mut BufRead, buffer: Vec } -impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { +impl<'a> Iterator for Iter<'a> { type Item = ::Result>; fn next(&mut self) -> Option<::Result>> { fn parse_time(c: &Context, date: &str, time: &str) -> Time { @@ -139,14 +139,13 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { } } -impl<'a, I: 'a> Decode<'a, I> for Weechat3 where I: BufRead { - type Output = Iter<'a, I>; - fn decode(&'a mut self, context: &'a Context, input: I) -> Iter<'a, I> { - Iter { +impl<'a> Decode<'a> for Weechat3 { + fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { + Box::new(Iter { context: context, input: input, buffer: Vec::new() - } + }) } } -- cgit v1.2.3