summaryrefslogtreecommitdiff
path: root/src/repo/parsers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo/parsers.rs')
-rw-r--r--src/repo/parsers.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/repo/parsers.rs b/src/repo/parsers.rs
new file mode 100644
index 0000000..ccef666
--- /dev/null
+++ b/src/repo/parsers.rs
@@ -0,0 +1,20 @@
+use mon::{Parser, ParserIter, ascii_alphanumeric, one_of};
+
+use crate::{Parseable, repo::Arch};
+
+impl<'a> Parseable<'a, &'a str> for Arch {
+ type Parser = impl Parser<&'a str, Output = Self>;
+
+ fn parser() -> Self::Parser {
+ let start = ascii_alphanumeric();
+ let rest = ascii_alphanumeric()
+ .or(one_of("-".chars()))
+ .repeated()
+ .many();
+
+ start
+ .and(rest)
+ .recognize()
+ .map(|output: &str| Arch(output.to_string()))
+ }
+}