aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Hoeppner2015-06-11 20:56:59 +0200
committerTill Hoeppner2015-06-11 20:56:59 +0200
commitccc9f5e8eaa84579da610ea0d90d18596078bac7 (patch)
tree52bed0ed50693bb9f5bbdc52fa81d7e1edfb855c
parent8361e508303d1573db7a0a5e892cfe2bdf42ffbb (diff)
downloadilc-ccc9f5e8eaa84579da610ea0d90d18596078bac7.tar.gz
ilc-ccc9f5e8eaa84579da610ea0d90d18596078bac7.tar.xz
ilc-ccc9f5e8eaa84579da610ea0d90d18596078bac7.zip
Fix binaries and eliminate warnings
-rw-r--r--src/context.rs1
-rw-r--r--src/event.rs5
-rw-r--r--src/format/binary.rs4
-rw-r--r--src/format/energymech.rs15
-rw-r--r--src/format/weechat3.rs14
-rw-r--r--src/freq.rs6
6 files changed, 16 insertions, 29 deletions
diff --git a/src/context.rs b/src/context.rs
index c24dd14..6626714 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -1,5 +1,4 @@
-use chrono::date::Date;
use chrono::naive::date::NaiveDate;
use chrono::offset::fixed::FixedOffset;
diff --git a/src/event.rs b/src/event.rs
index 0fab7ae..0ecb6bc 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -19,9 +19,6 @@ use std::borrow::Cow;
use chrono::offset::fixed::FixedOffset;
use chrono::offset::TimeZone;
-use chrono::datetime::DateTime;
-
-use context::Context;
/// A whole log, in memory. This structure does not specify its
/// use. It may represent a private query, or the log of a channel.
@@ -50,7 +47,7 @@ impl Time {
pub fn with_format(&self, tz: &FixedOffset, f: &str) -> String {
match self {
&Time::Unknown => panic!("Time data for this event is not present"),
- &Time::Hms(h, m, s) => unimplemented!(),
+ &Time::Hms(_h, _m, _s) => unimplemented!(),
&Time::Timestamp(t) => format!("{}", tz.timestamp(t, 0).format(f))
}
}
diff --git a/src/format/binary.rs b/src/format/binary.rs
index df57781..4c2e151 100644
--- a/src/format/binary.rs
+++ b/src/format/binary.rs
@@ -38,14 +38,14 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
}
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<()> {
+ fn encode(&'a self, _context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> {
bincode::encode_into(event, &mut output, SizeLimit::Infinite)
.map_err(|_| ::IlcError::BincodeEncode)
}
}
impl<'a, R: 'a> Decode<'a, R, Iter<'a, R>> for Binary where R: BufRead {
- fn decode(&'a mut self, context: &'a Context, input: R) -> Iter<R> {
+ fn decode(&'a mut self, _context: &'a Context, input: R) -> Iter<R> {
Iter { _phantom: PhantomData, input: input }
}
}
diff --git a/src/format/energymech.rs b/src/format/energymech.rs
index c52a654..e6f7d80 100644
--- a/src/format/energymech.rs
+++ b/src/format/energymech.rs
@@ -13,7 +13,7 @@
// limitations under the License.
use std::io::{ BufRead, Write };
-use std::borrow::{ ToOwned, Cow };
+use std::borrow::{ ToOwned };
use std::iter::{ Iterator };
use event::{ Event, Type, Time };
@@ -62,7 +62,7 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
info!("Original: `{}`", self.buffer);
info!("Parsing: {:?}", tokens);
}
- match tokens[..tokens.len() - 1].as_ref() {
+ match &tokens[..tokens.len() - 1] {
[time, "*", nick, content..] => return Some(Ok(Event {
ty: Type::Action {
from: nick.to_owned().into(),
@@ -124,24 +124,21 @@ impl<'a, R: 'a> Decode<'a, R, Iter<'a, R>> for Energymech where R: BufRead {
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<()> {
- fn date(t: i64) -> String {
- format!("[{}]", UTC.timestamp(t, 0).format(TIME_FORMAT))
- }
match event {
&Event { ty: Type::Msg { ref from, ref content }, ref time, .. } => {
- try!(writeln!(&mut output, "{} <{}> {}",
+ try!(writeln!(&mut output, "[{}] <{}> {}",
time.with_format(&context.timezone, TIME_FORMAT), from, content))
},
&Event { ty: Type::Action { ref from, ref content }, ref time, .. } => {
- try!(writeln!(&mut output, "{} * {} {}",
+ try!(writeln!(&mut output, "[{}] * {} {}",
time.with_format(&context.timezone, TIME_FORMAT), from, content))
},
&Event { ty: Type::Nick { ref old_nick, ref new_nick }, ref time, .. } => {
- try!(writeln!(&mut output, "{} *** {} is now known as {}",
+ try!(writeln!(&mut output, "[{}] *** {} is now known as {}",
time.with_format(&context.timezone, TIME_FORMAT), old_nick, new_nick))
},
&Event { ty: Type::Quit { ref nick, ref mask, ref reason }, ref time, .. } => {
- try!(writeln!(&mut output, "{} *** Quits: {} ({}) ({})",
+ try!(writeln!(&mut output, "[{}] *** Quits: {} ({}) ({})",
time.with_format(&context.timezone, TIME_FORMAT), nick,
mask.as_ref().expect("Mask not present, but required."),
reason.as_ref().expect("Reason not present, but required.")))
diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs
index 6ff5d5a..20ee1dd 100644
--- a/src/format/weechat3.rs
+++ b/src/format/weechat3.rs
@@ -13,9 +13,8 @@
// limitations under the License.
use std::io::{ BufRead, Write };
-use std::borrow::{ ToOwned, Cow, IntoCow };
+use std::borrow::{ ToOwned };
use std::iter::{ Iterator };
-use std::marker::PhantomData;
use event::{ Event, Type, Time };
use context::Context;
@@ -23,8 +22,6 @@ use format::{ Encode, Decode, rejoin, strip_one };
use l::LogLevel::Info;
-use chrono::*;
-
pub struct Weechat3;
static TIME_DATE_FORMAT: &'static str = "%Y-%m-%d %H:%M:%S";
@@ -36,8 +33,8 @@ pub struct Iter<'a, R: 'a> where R: BufRead {
}
impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
- type Item = ::Result<Event<'static>>;
- fn next(&mut self) -> Option<::Result<Event<'static>>> {
+ type Item = ::Result<Event<'a>>;
+ fn next(&mut self) -> Option<::Result<Event<'a>>> {
fn parse_time(c: &Context, date: &str, time: &str) -> Time {
Time::from_format(&c.timezone, &format!("{} {}", date, time), TIME_DATE_FORMAT)
}
@@ -140,7 +137,7 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
}
}
-impl<'a, R: 'a> Decode<'static, R, Iter<'a, R>> for Weechat3 where R: BufRead {
+impl<'a, R: 'a> Decode<'a, R, Iter<'a, R>> for Weechat3 where R: BufRead {
fn decode(&'a mut self, context: &'a Context, input: R) -> Iter<R> {
Iter {
context: context,
@@ -152,9 +149,6 @@ impl<'a, R: 'a> Decode<'static, R, Iter<'a, R>> for Weechat3 where R: BufRead {
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<()> {
- fn date(t: i64) -> String {
- format!("{}", UTC.timestamp(t, 0).format(TIME_DATE_FORMAT))
- }
match event {
&Event { ty: Type::Msg { ref from, ref content, .. }, ref time, .. } => {
try!(writeln!(&mut output, "{}\t{}\t{}",
diff --git a/src/freq.rs b/src/freq.rs
index 987499a..25810e7 100644
--- a/src/freq.rs
+++ b/src/freq.rs
@@ -21,7 +21,7 @@ use std::collections::hash_map::*;
use chrono::offset::fixed::FixedOffset;
use chrono::naive::date::NaiveDate;
-use ilc::event::Event::*;
+use ilc::event::{ Event, Type };
use ilc::context::Context;
use ilc::format::{ self, Decode };
@@ -51,7 +51,7 @@ fn main() {
override_date: NaiveDate::from_ymd(2015, 6, 10)
};
- let mut parser = format::energymech::Energymech;
+ let mut parser = format::weechat3::Weechat3;
for e in parser.decode(&context, stdin.lock()) {
let m = match e {
Ok(m) => m,
@@ -59,7 +59,7 @@ fn main() {
};
match m {
- Msg { ref from, ref content, .. } => {
+ Event { ty: Type::Msg { ref from, ref content, .. }, .. } => {
let nick = strip_nick(from);
if stats.contains_key(nick) {
let p: &mut Person = stats.get_mut(nick).unwrap();