Skip to main content

systemprompt_models/paths/
mod.rs

1//! Well-known directory layout helpers.
2//!
3//! [`AppPaths`] resolves the system, web, build, and storage path trees
4//! from a profile's [`crate::profile::PathsConfig`]. Submodules expose
5//! each tree plus shared directory/file-name constants.
6//! Resolution returns [`PathError`].
7
8mod build;
9pub mod constants;
10mod error;
11mod storage;
12mod system;
13mod web;
14
15pub use build::BuildPaths;
16pub use constants::{cloud_container, dir_names, file_names};
17pub use error::PathError;
18pub use storage::StoragePaths;
19pub use system::SystemPaths;
20pub use web::WebPaths;
21
22use std::path::Path;
23
24use crate::profile::PathsConfig;
25use systemprompt_extension::AssetPaths;
26
27#[derive(Debug, Clone)]
28pub struct AppPaths {
29    system: SystemPaths,
30    web: WebPaths,
31    build: BuildPaths,
32    storage: StoragePaths,
33}
34
35impl AppPaths {
36    pub fn from_profile(paths: &PathsConfig) -> Result<Self, PathError> {
37        Ok(Self {
38            system: SystemPaths::from_profile(paths)?,
39            web: WebPaths::from_profile(paths),
40            build: BuildPaths::from_profile(paths),
41            storage: StoragePaths::from_profile(paths)?,
42        })
43    }
44
45    pub const fn system(&self) -> &SystemPaths {
46        &self.system
47    }
48
49    pub const fn web(&self) -> &WebPaths {
50        &self.web
51    }
52
53    pub const fn build(&self) -> &BuildPaths {
54        &self.build
55    }
56
57    pub const fn storage(&self) -> &StoragePaths {
58        &self.storage
59    }
60}
61
62impl AssetPaths for AppPaths {
63    fn storage_files(&self) -> &Path {
64        self.storage.files()
65    }
66
67    fn web_dist(&self) -> &Path {
68        self.web.dist()
69    }
70}