rename mode to feature

This commit is contained in:
yggverse 2025-01-15 06:48:17 +02:00
parent 042ace98d3
commit 7e7b769c11
2 changed files with 17 additions and 17 deletions

View File

@ -1,7 +1,7 @@
mod mode;
mod feature;
mod uri;
use mode::Mode;
use feature::Feature;
use gtk::glib::{Uri, UriFlags};
@ -16,19 +16,19 @@ impl Protocol {
/// Create new `Self` from parsable request string
pub fn from_string(request: &str) -> Self {
match Mode::from_string(request) {
Mode::Default { request } | Mode::Download { request } | Mode::Source { request } => {
match Uri::parse(&request, UriFlags::NONE) {
Ok(uri) => match uri.scheme().as_str() {
"gemini" => Self::Gemini { uri },
"titan" => Self::Titan { uri },
_ => Self::Undefined,
},
Err(_) => Self::Gemini {
uri: uri::tgls(&request),
},
}
}
match Feature::from_string(request) {
Feature::Default { request }
| Feature::Download { request }
| Feature::Source { request } => match Uri::parse(&request, UriFlags::NONE) {
Ok(uri) => match uri.scheme().as_str() {
"gemini" => Self::Gemini { uri },
"titan" => Self::Titan { uri },
_ => Self::Undefined,
},
Err(_) => Self::Gemini {
uri: uri::tgls(&request),
},
},
}
}
}

View File

@ -1,10 +1,10 @@
pub enum Mode {
pub enum Feature {
Default { request: String },
Download { request: String },
Source { request: String },
}
impl Mode {
impl Feature {
// Constructors
/// Parse new `Self` from string