From 55b915a75f49957eaddefa74cbbf572ad186ee2f Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Mon, 3 Nov 2014 16:39:57 +0100 Subject: API improvements, but more copying --- src/event.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/event.rs (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs new file mode 100644 index 0000000..7e280a9 --- /dev/null +++ b/src/event.rs @@ -0,0 +1,33 @@ +use ident::Ident; + +#[deriving(Clone)] +pub struct Event { + pub prefix: String, + pub command: String, + pub content: String +} + +pub trait ParseResult { + fn parse(event: Event) -> Option; +} + +pub const PRIVMSG: &'static str = "PRIVMSG"; + +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[]); + match from { + Some(from) => Some(PrivMsg { + from: from, + content: event.content + }), + None => None + } + } +} -- cgit v1.2.3