mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
format request, begin download feature implementation
This commit is contained in:
parent
88b3adaf2d
commit
09f2a17f22
6 changed files with 533 additions and 187 deletions
34
src/app/browser/window/tab/item/page/request.rs
Normal file
34
src/app/browser/window/tab/item/page/request.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use gtk::glib::{Uri, UriFlags};
|
||||
|
||||
/// Request type for `Page` with optional value parsed
|
||||
pub enum Request {
|
||||
Default(Uri),
|
||||
Download(Uri),
|
||||
Source(Uri),
|
||||
Search(String),
|
||||
}
|
||||
|
||||
impl Request {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self` from `request` string
|
||||
pub fn from(request: &str) -> Self {
|
||||
if let Some(postfix) = request.strip_prefix("source:") {
|
||||
if let Ok(uri) = Uri::parse(postfix, UriFlags::NONE) {
|
||||
return Self::Source(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(postfix) = request.strip_prefix("download:") {
|
||||
if let Ok(uri) = Uri::parse(postfix, UriFlags::NONE) {
|
||||
return Self::Download(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(uri) = Uri::parse(request, UriFlags::NONE) {
|
||||
return Self::Default(uri);
|
||||
}
|
||||
|
||||
Self::Search(request.to_string())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue