From f01c278a26e0f248d188c10bdb852b0859b98b3b Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Tue, 23 Feb 2016 17:00:53 +0100 Subject: Test CI --- src/format/mod.rs | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/format/mod.rs') diff --git a/src/format/mod.rs b/src/format/mod.rs index cea6855..8873db8 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -17,7 +17,7 @@ //! target format, all formats must allow for omittable information. use std::iter; -use std::io::{ BufRead, Write }; +use std::io::{BufRead, Write}; use std::borrow::Cow; use event::Event; @@ -35,17 +35,27 @@ mod binary; mod msgpack; pub trait Encode { - fn encode<'a>(&'a self, context: &'a Context, output: &'a mut Write, event: &'a Event) -> ::Result<()>; + fn encode<'a>(&'a self, + context: &'a Context, + output: &'a mut Write, + event: &'a Event) + -> ::Result<()>; } pub trait Decode { - fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a>; + fn decode<'a>(&'a mut self, + context: &'a Context, + input: &'a mut BufRead) + -> Box>> + 'a>; } pub struct Dummy; impl Decode for Dummy { - fn decode<'a>(&'a mut self, _context: &'a Context, _input: &'a mut BufRead) -> Box>> + 'a> { + fn decode<'a>(&'a mut self, + _context: &'a Context, + _input: &'a mut BufRead) + -> Box>> + 'a> { Box::new(iter::empty()) } } @@ -54,10 +64,10 @@ pub fn decoder(format: &str) -> Option> { match format { "energymech" | "em" => Some(Box::new(Energymech)), "weechat" | "w" => Some(Box::new(Weechat)), -// "irssi" => Some(Box::new(irssi::Irssi)), + // "irssi" => Some(Box::new(irssi::Irssi)), "binary" => Some(Box::new(Binary)), "msgpack" => Some(Box::new(Msgpack)), - _ => None + _ => None, } } @@ -65,18 +75,24 @@ pub fn encoder(format: &str) -> Option> { match format { "energymech" | "em" => Some(Box::new(Energymech)), "weechat" | "w" => Some(Box::new(Weechat)), -// "irssi" => Some(Box::new(irssi::Irssi)), + // "irssi" => Some(Box::new(irssi::Irssi)), "binary" => Some(Box::new(Binary)), "msgpack" => Some(Box::new(Msgpack)), - _ => None + _ => None, } } fn rejoin(s: &[&str], splits: &[char]) -> Cow<'static, str> { 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) + 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) } fn strip_one(s: &str) -> String { -- cgit v1.2.3