From bb94e44ed6ec5b55823270192c00904cbfb24b6b Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Sat, 18 Apr 2015 13:35:38 +0200 Subject: I forgot to keep track. Embarassing, huh? --- src/event.rs | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/event.rs (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs deleted file mode 100644 index b8e9743..0000000 --- a/src/event.rs +++ /dev/null @@ -1,50 +0,0 @@ -use ident::Ident; - -use std::borrow::ToOwned; - -#[deriving(Clone)] -pub struct Event { - pub prefix: String, - pub command: String, - pub content: Vec -} - -pub trait ParseResult { - fn parse(event: Event) -> Option; -} - -pub const PING: &'static str = "PING"; - -pub const PRIVMSG: &'static str = "PRIVMSG"; - -fn join(v: Vec, from: uint) -> String { - let mut msg = if v[from].chars().next().unwrap() == ':' { - v[from][][1..].to_owned() - } else { v[from].clone() }; - for m in v.iter().skip(from + 1) { - msg.push_str(" "); - msg.push_str(m.trim_right()); - } - msg -} - -pub struct PrivMsg { - pub from: Ident, - pub to: String, - pub content: String -} - -impl ParseResult for PrivMsg { - fn parse(event: Event) -> Option { - let from = Ident::parse(event.prefix[]); - let to = event.content[0].clone(); - match from { - Some(from) => Some(PrivMsg { - from: from, - to: to, - content: join(event.content, 1) - }), - None => None - } - } -} -- cgit v1.2.3