2021-04-11 01:09:09 +03:00
|
|
|
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2020-06-28 16:34:43 +03:00
|
|
|
//! Tauri utility helpers
|
|
|
|
#![warn(missing_docs, rust_2018_idioms)]
|
|
|
|
|
2021-02-09 21:22:04 +03:00
|
|
|
/// The Assets module allows you to read files that have been bundled by tauri
|
|
|
|
pub mod assets;
|
|
|
|
/// Tauri config definition.
|
|
|
|
pub mod config;
|
2021-05-05 05:31:05 +03:00
|
|
|
/// Tauri HTML processing.
|
|
|
|
pub mod html;
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Platform helpers
|
2020-01-18 03:33:17 +03:00
|
|
|
pub mod platform;
|
|
|
|
|
2021-05-10 06:01:12 +03:00
|
|
|
/// `App` package information.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct PackageInfo {
|
|
|
|
/// App name.
|
|
|
|
pub name: String,
|
|
|
|
/// App version.
|
|
|
|
pub version: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PackageInfo {
|
|
|
|
/// Returns the application package name.
|
|
|
|
/// On macOS and Windows it's the `name` field, and on Linux it's the `name` in `kebab-case`.
|
|
|
|
pub fn package_name(&self) -> String {
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
{
|
|
|
|
use heck::KebabCase;
|
|
|
|
self.name.to_kebab_case()
|
|
|
|
}
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
return self.name.clone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-11 01:51:15 +03:00
|
|
|
/// Result type alias using the crate's error type.
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
2020-01-18 03:33:17 +03:00
|
|
|
|
2020-06-28 16:34:43 +03:00
|
|
|
/// The error types.
|
2021-02-11 01:51:15 +03:00
|
|
|
#[derive(Debug, thiserror::Error)]
|
2021-05-06 04:22:45 +03:00
|
|
|
#[non_exhaustive]
|
2020-05-30 02:22:04 +03:00
|
|
|
pub enum Error {
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Target triple architecture error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Unable to determine target-architecture")]
|
|
|
|
Architecture,
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Target triple OS error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Unable to determine target-os")]
|
2021-04-12 16:44:44 +03:00
|
|
|
Os,
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Target triple environment error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Unable to determine target-environment")]
|
|
|
|
Environment,
|
2021-02-11 01:51:15 +03:00
|
|
|
/// Tried to get resource on an unsupported platform.
|
|
|
|
#[error("Unsupported platform for reading resources")]
|
|
|
|
UnsupportedPlatform,
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Get parent process error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Could not get parent process")]
|
|
|
|
ParentProcess,
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Get parent process PID error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Could not get parent PID")]
|
2021-04-12 16:44:44 +03:00
|
|
|
ParentPid,
|
2020-06-28 16:34:43 +03:00
|
|
|
/// Get child process error
|
2020-06-18 00:11:11 +03:00
|
|
|
#[error("Could not get child process")]
|
|
|
|
ChildProcess,
|
2021-02-11 01:51:15 +03:00
|
|
|
/// IO error.
|
|
|
|
#[error("{0}")]
|
|
|
|
Io(#[from] std::io::Error),
|
2020-06-18 00:11:11 +03:00
|
|
|
}
|