aboutsummaryrefslogtreecommitdiff
path: root/src/ident.rs
diff options
context:
space:
mode:
authorTill Hoeppner2014-10-21 15:33:17 +0200
committerTill Hoeppner2014-10-21 16:15:10 +0200
commitfc27f8cee888acf70683badca9edadb45544822c (patch)
treef39314f857e92a1e5a19f9675205750adf8919f0 /src/ident.rs
parentce640c2c25b0e16c567553c5774d633c13cbf0ee (diff)
downloadirsc-fc27f8cee888acf70683badca9edadb45544822c.tar.gz
irsc-fc27f8cee888acf70683badca9edadb45544822c.tar.xz
irsc-fc27f8cee888acf70683badca9edadb45544822c.zip
Initial commit.
Diffstat (limited to 'src/ident.rs')
-rw-r--r--src/ident.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ident.rs b/src/ident.rs
new file mode 100644
index 0000000..069e186
--- /dev/null
+++ b/src/ident.rs
@@ -0,0 +1,24 @@
+use regex::Regex;
+
+static PATTERN: Regex = regex!(":(.*)!(.*)@(.*)");
+
+#[deriving(Show, Clone)]
+pub struct Ident {
+ pub nickname: String,
+ pub user: String,
+ pub host: String
+}
+
+impl Ident {
+ pub fn parse(s: &str) -> Option<Ident> {
+ let c = match PATTERN.captures(s) {
+ Some(c) => c,
+ None => return None
+ };
+ Some(Ident {
+ nickname: c.at(1).into_string(),
+ user: c.at(2).into_string(),
+ host: c.at(3).into_string()
+ })
+ }
+}