mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
use const
This commit is contained in:
parent
10539a1d30
commit
c80a31af9c
1 changed files with 8 additions and 6 deletions
|
|
@ -13,6 +13,8 @@ use sqlite::Transaction;
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::Cell, rc::Rc};
|
||||||
|
|
||||||
const PLACEHOLDER_TEXT: &str = "URL or search term...";
|
const PLACEHOLDER_TEXT: &str = "URL or search term...";
|
||||||
|
const PREFIX_DOWNLOAD: &str = "download:";
|
||||||
|
const PREFIX_SOURCE: &str = "source:";
|
||||||
|
|
||||||
pub trait Request {
|
pub trait Request {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
@ -252,14 +254,14 @@ impl Request for Entry {
|
||||||
strip_prefix(self.text())
|
strip_prefix(self.text())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get request value in `download:` format
|
/// Get request value with formatted `download` prefix
|
||||||
fn download(&self) -> GString {
|
fn download(&self) -> GString {
|
||||||
gformat!("download:{}", self.strip_prefix())
|
gformat!("{PREFIX_DOWNLOAD}{}", self.strip_prefix())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get request value in `source:` format
|
/// Get request value with formatted `source` prefix
|
||||||
fn source(&self) -> GString {
|
fn source(&self) -> GString {
|
||||||
gformat!("source:{}", self.strip_prefix())
|
gformat!("{PREFIX_SOURCE}{}", self.strip_prefix())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try get current request value as [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
/// Try get current request value as [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
||||||
|
|
@ -292,11 +294,11 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
/// Strip system prefix from request string
|
/// Strip system prefix from request string
|
||||||
/// * the `prefix` is not `scheme`
|
/// * the `prefix` is not `scheme`
|
||||||
fn strip_prefix(mut request: GString) -> GString {
|
fn strip_prefix(mut request: GString) -> GString {
|
||||||
if let Some(postfix) = request.strip_prefix("source:") {
|
if let Some(postfix) = request.strip_prefix(PREFIX_SOURCE) {
|
||||||
request = postfix.into()
|
request = postfix.into()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(postfix) = request.strip_prefix("download:") {
|
if let Some(postfix) = request.strip_prefix(PREFIX_DOWNLOAD) {
|
||||||
request = postfix.into()
|
request = postfix.into()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue