52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
// (catalog_name, (username, password))
|
|
pub type CatalogDefinition<'a> = (&'a str, Login<'a>);
|
|
pub type Login<'a> = Option<(&'a str, &'a str)>;
|
|
|
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
pub static ALIASES: &[(&str, CatalogDefinition)] = &[
|
|
("DS_WS1617", ("16w-diskrete-strukturen", None)),
|
|
("EIDI_WS1617", ("eidi1-2016", Some(("eidi-2016", "PGdP.16")))),
|
|
("ERA_WS1617", ("era-2016", None)),
|
|
|
|
("GAD_SS17", ("17s-grundlagen-algorithmen-und-datenstrukturen", None)),
|
|
("LA_SS17", ("17s-lineare-algebra-fuer-informatik", None)),
|
|
// EIST is on a Nextcloud
|
|
];
|
|
|
|
pub static ALIAS_ALIASES: &[(&str, &str)] = &[
|
|
("DS", "DS_WS1617"),
|
|
("EIDI", "EIDI_WS1617"),
|
|
("ERA", "ERA_WS1617"),
|
|
|
|
("GAD", "GAD_SS17"),
|
|
("LA", "LA_SS17"),
|
|
];
|
|
|
|
pub fn resolve_alias(mut query: &str) -> Option<CatalogDefinition> {
|
|
for &(alias_alias, alias) in ALIAS_ALIASES {
|
|
if query == alias_alias {
|
|
query = alias;
|
|
}
|
|
}
|
|
|
|
for &(alias_name, def) in ALIASES {
|
|
if query == alias_name {
|
|
return Some(def);
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn check_alias_aliases() {
|
|
for &(alias, _) in ALIAS_ALIASES {
|
|
assert!(resolve_alias(alias).is_some());
|
|
}
|
|
}
|
|
}
|