systemprompt_models/paths/
mod.rs1pub(crate) mod build;
12pub mod constants;
13mod error;
14mod storage;
15mod system;
16mod web;
17
18pub use build::BuildPaths;
19pub use constants::{cloud_container, dir_names, file_names};
20pub use error::PathError;
21pub use storage::StoragePaths;
22pub use system::SystemPaths;
23pub use web::WebPaths;
24
25use std::path::Path;
26
27use crate::profile::PathsConfig;
28use systemprompt_extension::AssetPaths;
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub enum PathResolution {
34 Canonicalize,
35 Lexical,
36}
37
38#[derive(Debug, Clone)]
39pub struct AppPaths {
40 system: SystemPaths,
41 web: WebPaths,
42 build: BuildPaths,
43 storage: StoragePaths,
44}
45
46impl AppPaths {
47 pub fn from_profile(
48 paths: &PathsConfig,
49 resolution: PathResolution,
50 services_root_override: Option<&Path>,
51 ) -> Result<Self, PathError> {
52 let overridden = services_root_override.map(|root| paths.with_services_root(root));
53 let paths = overridden.as_ref().unwrap_or(paths);
54 Ok(Self {
55 system: SystemPaths::from_profile(paths, resolution)?,
56 web: WebPaths::from_profile(paths),
57 build: BuildPaths::from_profile(paths),
58 storage: StoragePaths::from_profile(paths)?,
59 })
60 }
61
62 pub const fn system(&self) -> &SystemPaths {
63 &self.system
64 }
65
66 pub const fn web(&self) -> &WebPaths {
67 &self.web
68 }
69
70 pub const fn build(&self) -> &BuildPaths {
71 &self.build
72 }
73
74 pub const fn storage(&self) -> &StoragePaths {
75 &self.storage
76 }
77}
78
79impl AssetPaths for AppPaths {
80 fn storage_files(&self) -> &Path {
81 self.storage.files()
82 }
83
84 fn web_dist(&self) -> &Path {
85 self.web.dist()
86 }
87}