From b2d8cce90a50e7e68d425a6c692ce401d63de171 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Sat, 23 Jan 2016 17:18:39 +0100 Subject: Fix compilation, fix dependencies --- Cargo.toml | 26 ++++++++++++-------------- src/format/energymech.rs | 8 ++++---- src/format/mod.rs | 30 +++++++++++++++--------------- src/format/weechat3.rs | 8 ++++---- src/lib.rs | 4 +--- src/main.rs | 41 +++++++++++++++++------------------------ 6 files changed, 53 insertions(+), 64 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7978cd7..7f0e2a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ilc" -version = "0.0.1" +version = "0.1.0" license = "Apache-2.0" authors = ["Till Hoeppner "] @@ -10,19 +10,17 @@ name = "ilc" doc = false [dependencies] -regex = "*" -regex_macros = "*" -chrono = "*" -docopt = "*" -rustc-serialize = "*" -log = "*" -env_logger = "*" -bincode = "*" -combine = "*" -glob = "*" -rmp = "*" -rmp-serialize = "*" -blist = "*" +regex = "0.1.46" +chrono = "0.2.18" +docopt = "0.6.78" +rustc-serialize = "0.3.16" +log = "0.3.4" +env_logger = "0.3.2" +bincode = "0.4.0" +glob = "0.2.10" +rmp = "0.7.3" +rmp-serialize = "0.7.0" +blist = "0.0.4" [profile.release] opt-level = 3 diff --git a/src/format/energymech.rs b/src/format/energymech.rs index 5965dfa..ba82458 100644 --- a/src/format/energymech.rs +++ b/src/format/energymech.rs @@ -153,8 +153,8 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> Decode<'a> for Energymech { - fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { +impl Decode for Energymech { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { Box::new(Iter { context: context, input: input, @@ -163,8 +163,8 @@ impl<'a> Decode<'a> for Energymech { } } -impl<'a, W> Encode<'a, W> for Energymech where W: Write { - fn encode(&'a self, context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> { +impl Encode for Energymech { + fn encode<'a>(&'a self, context: &'a Context, mut output: &'a mut Write, event: &'a Event) -> ::Result<()> { match event { &Event { ty: Type::Msg { ref from, ref content }, ref time, .. } => { try!(writeln!(&mut output, "[{}] <{}> {}", diff --git a/src/format/mod.rs b/src/format/mod.rs index 4f8eaa1..370a92b 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -23,41 +23,41 @@ use std::borrow::Cow; use event::Event; use context::Context; -//pub mod weechat3; -//pub mod energymech; +pub mod energymech; +pub mod weechat3; //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 Encode { + fn encode<'a>(&'a self, context: &'a Context, output: &'a mut Write, event: &'a Event) -> ::Result<()>; } -pub trait Decode<'a, 'b, 'c> { - fn decode(&'a mut self, context: &'b Context, input: &'c mut BufRead) -> Box>> + 'a>; +pub trait Decode { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a>; } pub struct Dummy; -impl <'a, 'b, 'c> Decode<'a, 'b, 'c> for Dummy { - fn decode(&'a mut self, _context: &'b Context, _input: &'c mut BufRead) -> Box>> + 'a> { +impl Decode for Dummy { + fn decode<'a>(&'a mut self, _context: &'a Context, _input: &'a mut BufRead) -> Box>> + 'a> { Box::new(iter::empty()) } } -pub fn decoder<'a, 'b, 'c>(format: &str) -> Option>> { +pub fn decoder(format: &str) -> Option> { match format { -// "energymech" => Some(Box::new(energymech::Energymech)), -// "weechat3" => Some(Box::new(weechat3::Weechat3)), + "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, 'b: 'a>(format: &str) -> Option>> { +pub fn encoder(format: &str) -> Option> { match format { -// "energymech" => Some(Box::new(energymech::Energymech)), -// "weechat3" => Some(Box::new(weechat3::Weechat3)), + "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 @@ -65,7 +65,7 @@ pub fn encoder<'a, 'b: 'a>(format: &str) -> Option } fn rejoin(s: &[&str], splits: &[char]) -> Cow<'static, str> { - let len = s.iter().map(|s| s.len()).sum(); + let len = s.iter().map(|s| s.len()).fold(0, |a, b| a + b); let mut out = s.iter().zip(splits.iter()).fold(String::with_capacity(len), |mut s, (b, &split)| { s.push_str(b); s.push(split); s }); out.pop(); Cow::Owned(out) diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index 118bd3b..92da0e0 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -139,8 +139,8 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> Decode<'a> for Weechat3 { - fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { +impl Decode for Weechat3 { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { Box::new(Iter { context: context, input: input, @@ -149,8 +149,8 @@ impl<'a> Decode<'a> for Weechat3 { } } -impl<'a, W> Encode<'a, W> for Weechat3 where W: Write { - fn encode(&'a self, context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> { +impl Encode for Weechat3 { + fn encode<'a>(&'a self, context: &'a Context, mut output: &'a mut Write, event: &'a Event) -> ::Result<()> { match event { &Event { ty: Type::Msg { ref from, ref content, .. }, ref time, .. } => { try!(writeln!(&mut output, "{}\t{}\t{}", diff --git a/src/lib.rs b/src/lib.rs index 015af7d..e1b2db5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(plugin, slice_patterns, custom_derive, iter_arith)] -#![plugin(regex_macros)] -extern crate regex; +#![feature(slice_patterns)] extern crate chrono; #[macro_use] extern crate log as l; diff --git a/src/main.rs b/src/main.rs index 285995c..c97d8aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,15 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(libc, plugin)] -#![plugin(regex_macros)] - extern crate ilc; extern crate chrono; extern crate docopt; extern crate rustc_serialize; -extern crate libc; -extern crate regex; #[macro_use] extern crate log; extern crate env_logger; @@ -116,7 +111,7 @@ fn die(s: &str) -> ! { process::exit(1) } -fn force_decoder<'a, 'b, 'c>(s: Option) -> Box> { +fn force_decoder(s: Option) -> Box { let inf = match s { Some(s) => s, None => die("You didn't specify the input format") @@ -127,7 +122,7 @@ fn force_decoder<'a, 'b, 'c>(s: Option) -> Box> { } } -fn force_encoder<'a, 'b: 'a>(s: Option) -> Box> { +fn force_encoder<'a>(s: Option) -> Box { let outf = match s { Some(s) => s, None => die("You didn't specify the output format") @@ -167,28 +162,26 @@ fn main() { Box::new(BufReader::new(io::stdin())) }; - /*let mut output: Box = if let Some(out) = args.flag_out { + let mut output: Box = if let Some(out) = args.flag_out { match File::create(out) { Ok(f) => Box::new(BufWriter::new(f)), Err(e) => error(Box::new(e)) } } else { Box::new(BufWriter::new(io::stdout())) - };*/ + }; - //if args.cmd_parse { - let mut i = io::empty(); - let mut decoder: Box = Box::new(format::Dummy);//force_decoder(args.flag_inf); - // let encoder = force_encoder(args.flag_outf); - let iter = decoder.decode(&context, &mut i); - //for e in decoder.decode_box(&context, &mut input) { - //let e = e.unwrap(); - //let _ = encoder.encode(&context, &mut output, &e); - //} - /*}*/ /*else if args.cmd_convert { + if args.cmd_parse { let mut decoder = force_decoder(args.flag_inf); let encoder = force_encoder(args.flag_outf); - for e in decoder.decode_box(&context, &mut input) { + for e in decoder.decode(&context, &mut input) { + let e = e.unwrap(); + let _ = encoder.encode(&context, &mut output, &e); + } + }else if args.cmd_convert { + let mut decoder = force_decoder(args.flag_inf); + let encoder = force_encoder(args.flag_outf); + for e in decoder.decode(&context, &mut input) { match e { Ok(e) => { let _ = encoder.encode(&context, &mut output, &e); }, Err(e) => error(Box::new(e)) @@ -215,7 +208,7 @@ fn main() { let mut stats: HashMap = HashMap::new(); let mut decoder = force_decoder(args.flag_inf); - for e in decoder.decode_box(&context, &mut input) { + for e in decoder.decode(&context, &mut input) { let m = match e { Ok(m) => m, Err(err) => error(Box::new(err)) @@ -248,7 +241,7 @@ fn main() { } else if args.cmd_sort { let mut decoder = force_decoder(args.flag_inf); let encoder = force_encoder(args.flag_outf); - let mut events: Vec = decoder.decode_box(&context, &mut input) + let mut events: Vec = decoder.decode(&context, &mut input) .flat_map(Result::ok) .collect(); @@ -261,7 +254,7 @@ fn main() { let encoder = force_encoder(args.flag_outf); let mut backlog = AgeSet::new(); - for e in decoder.decode_box(&context, &mut input) { + for e in decoder.decode(&context, &mut input) { if let Ok(e) = e { let newest_event = e.clone(); backlog.prune(move |a: &NoTimeHash| { @@ -276,5 +269,5 @@ fn main() { } } } - }*/ + } } -- cgit v1.2.3