tauri_utils/
lib.rs

1// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5//! Tauri utility helpers
6#![warn(missing_docs, rust_2018_idioms)]
7
8/// The Assets module allows you to read files that have been bundled by tauri
9pub mod assets;
10/// Tauri config definition.
11pub mod config;
12/// Tauri HTML processing.
13pub mod html;
14/// Platform helpers
15pub mod platform;
16
17/// `App` package information.
18#[derive(Debug, Clone)]
19pub struct PackageInfo {
20  /// App name.
21  pub name: String,
22  /// App version.
23  pub version: String,
24}
25
26impl PackageInfo {
27  /// Returns the application package name.
28  /// On macOS and Windows it's the `name` field, and on Linux it's the `name` in `kebab-case`.
29  pub fn package_name(&self) -> String {
30    self.name.clone()
31  }
32}
33
34/// Result type alias using the crate's error type.
35pub type Result<T> = std::result::Result<T, Error>;
36
37/// The error types.
38#[derive(Debug, thiserror::Error)]
39#[non_exhaustive]
40pub enum Error {
41  /// Target triple architecture error
42  #[error("Unable to determine target-architecture")]
43  Architecture,
44  /// Target triple OS error
45  #[error("Unable to determine target-os")]
46  Os,
47  /// Target triple environment error
48  #[error("Unable to determine target-environment")]
49  Environment,
50  /// Tried to get resource on an unsupported platform.
51  #[error("Unsupported platform for reading resources")]
52  UnsupportedPlatform,
53  /// Get parent process error
54  #[error("Could not get parent process")]
55  ParentProcess,
56  /// Get parent process PID error
57  #[error("Could not get parent PID")]
58  ParentPid,
59  /// Get child process error
60  #[error("Could not get child process")]
61  ChildProcess,
62  /// IO error.
63  #[error("{0}")]
64  Io(#[from] std::io::Error),
65}