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