mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
42 lines
962 B
Rust
42 lines
962 B
Rust
// Feature conversion prefixes
|
|
const DOWNLOAD: &str = "download:";
|
|
const SOURCE: &str = "source:";
|
|
|
|
/// Feature wrapper for client `Request`
|
|
#[derive(Default)]
|
|
pub enum Feature {
|
|
#[default]
|
|
Default,
|
|
Download,
|
|
Source,
|
|
// @TODO System(Action)
|
|
}
|
|
|
|
impl Feature {
|
|
// Constructors
|
|
|
|
/// Parse new `Self` from navigation entry request
|
|
pub fn parse(request: &str) -> (Self, &str) {
|
|
if let Some(postfix) = request.strip_prefix(DOWNLOAD) {
|
|
return (Self::Download, postfix);
|
|
}
|
|
|
|
if let Some(postfix) = request.strip_prefix(SOURCE) {
|
|
return (Self::Source, postfix);
|
|
}
|
|
|
|
(Self::Default, request)
|
|
}
|
|
|
|
// Getters
|
|
|
|
/* @TODO not in use
|
|
/// Get `Self` as prefix
|
|
pub fn as_prefix(&self) -> Option<&str> {
|
|
match self {
|
|
Self::Download => Some(DOWNLOAD),
|
|
Self::Source => Some(SOURCE),
|
|
Self::Default => None,
|
|
}
|
|
}*/
|
|
}
|