2023-05-24 11:20:13 +02:00
|
|
|
use lazy_static::lazy_static;
|
2024-07-29 19:33:58 +02:00
|
|
|
use serde::Serialize;
|
2024-01-28 14:35:17 +01:00
|
|
|
use shadow_rs::{is_debug, shadow};
|
2024-07-29 19:33:58 +02:00
|
|
|
use std::env::current_exe;
|
|
|
|
use std::path::PathBuf;
|
2023-06-25 15:29:52 +02:00
|
|
|
|
|
|
|
shadow!(build);
|
2023-04-20 16:02:41 +02:00
|
|
|
|
2023-05-24 11:20:13 +02:00
|
|
|
lazy_static! {
|
2024-01-28 14:35:17 +01:00
|
|
|
pub static ref RESOURCE_PATH: PathBuf = if is_debug() {
|
|
|
|
let project_root = build::CARGO_MANIFEST_DIR.parse::<PathBuf>().unwrap();
|
|
|
|
project_root.join("./tmp/resources")
|
|
|
|
} else {
|
|
|
|
current_exe()
|
|
|
|
.unwrap()
|
|
|
|
.parent()
|
|
|
|
.unwrap()
|
|
|
|
.join("../share/upend")
|
|
|
|
};
|
|
|
|
pub static ref WEBUI_PATH: PathBuf = RESOURCE_PATH.join("webui");
|
2023-06-25 15:29:52 +02:00
|
|
|
static ref APP_USER_AGENT: String = format!("upend / {}", build::PKG_VERSION);
|
2023-05-24 11:20:13 +02:00
|
|
|
pub static ref REQWEST_CLIENT: reqwest::blocking::Client = reqwest::blocking::Client::builder()
|
|
|
|
.user_agent(APP_USER_AGENT.as_str())
|
|
|
|
.build()
|
|
|
|
.unwrap();
|
2023-06-06 19:01:38 +02:00
|
|
|
pub static ref REQWEST_ASYNC_CLIENT: reqwest::Client = reqwest::Client::builder()
|
|
|
|
.user_agent(APP_USER_AGENT.as_str())
|
|
|
|
.build()
|
|
|
|
.unwrap();
|
2023-05-24 11:20:13 +02:00
|
|
|
}
|
2023-10-22 21:18:00 +02:00
|
|
|
|
|
|
|
pub fn get_version() -> &'static str {
|
|
|
|
option_env!("UPEND_VERSION").unwrap_or("unknown")
|
2023-11-17 17:23:08 +01:00
|
|
|
}
|
2024-07-29 19:33:58 +02:00
|
|
|
|
|
|
|
pub trait UserDescribable {
|
|
|
|
fn name(&self) -> &'static str;
|
|
|
|
fn description(&self) -> Option<&'static str> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
fn icon(&self) -> Option<&'static str> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
fn full_description(&self) -> UserDescription {
|
|
|
|
UserDescription {
|
|
|
|
name: self.name(),
|
|
|
|
description: self.description(),
|
|
|
|
icon: self.icon(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct UserDescription {
|
|
|
|
pub name: &'static str,
|
|
|
|
pub description: Option<&'static str>,
|
|
|
|
pub icon: Option<&'static str>,
|
|
|
|
}
|