diff options
author | Till Hoeppner | 2015-07-29 00:01:46 +0200 |
---|---|---|
committer | Till Hoeppner | 2015-07-29 00:01:46 +0200 |
commit | 09f6509050f24e54c9859e0905e8b6731d91f39f (patch) | |
tree | 1916aaf8e8bb6d978000f4233bbe690228256ef7 /src/format/energymech.rs | |
parent | 434048f7252c2490f04866c9a08eff6eb1688dc3 (diff) | |
download | ilc-09f6509050f24e54c9859e0905e8b6731d91f39f.tar.gz ilc-09f6509050f24e54c9859e0905e8b6731d91f39f.tar.xz ilc-09f6509050f24e54c9859e0905e8b6731d91f39f.zip |
implement sort and dedup of logs
Diffstat (limited to 'src/format/energymech.rs')
-rw-r--r-- | src/format/energymech.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/format/energymech.rs b/src/format/energymech.rs index 0e46dce..df48318 100644 --- a/src/format/energymech.rs +++ b/src/format/energymech.rs @@ -31,7 +31,7 @@ static TIME_FORMAT: &'static str = "%H:%M:%S"; pub struct Iter<'a, R: 'a> where R: BufRead { context: &'a Context, input: R, - buffer: String + buffer: Vec<u8> } impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { @@ -54,18 +54,20 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { loop { self.buffer.clear(); - match self.input.read_line(&mut self.buffer) { + match self.input.read_until(b'\n', &mut self.buffer) { Ok(0) | Err(_) => return None, Ok(_) => () } + let buffer = String::from_utf8_lossy(&self.buffer); + let mut split_tokens: Vec<char> = Vec::new(); - let tokens = self.buffer.split( |c: char| { + let tokens = buffer.split( |c: char| { if c.is_whitespace() { split_tokens.push(c); true } else { false } }).collect::<Vec<_>>(); if log_enabled!(Info) { - info!("Original: `{}`", self.buffer); + info!("Original: `{}`", buffer); info!("Parsing: {:?}", tokens); } @@ -157,7 +159,7 @@ impl<'a, R: 'a> Decode<'a, R> for Energymech where R: BufRead { Iter { context: context, input: input, - buffer: String::new() + buffer: Vec::new() } } } |