systemprompt_models/paths/
storage.rs1use std::path::{Path, PathBuf};
2
3use super::PathError;
4use crate::profile::PathsConfig;
5
6#[derive(Debug, Clone)]
7pub struct StoragePaths {
8 root: PathBuf,
9 files: PathBuf,
10 css: PathBuf,
11 js: PathBuf,
12 fonts: PathBuf,
13 images: PathBuf,
14 generated_images: PathBuf,
15 logos: PathBuf,
16 audio: PathBuf,
17 video: PathBuf,
18 documents: PathBuf,
19 uploads: PathBuf,
20}
21
22impl StoragePaths {
23 pub fn from_profile(paths: &PathsConfig) -> Result<Self, PathError> {
24 let root = paths
25 .storage
26 .as_ref()
27 .ok_or(PathError::NotConfigured { field: "storage" })?;
28
29 let root = PathBuf::from(root);
30 let files = root.join("files");
31
32 Ok(Self {
33 css: files.join("css"),
34 js: files.join("js"),
35 fonts: files.join("fonts"),
36 images: files.join("images"),
37 generated_images: files.join("images/generated"),
38 logos: files.join("images/logos"),
39 audio: files.join("audio"),
40 video: files.join("video"),
41 documents: files.join("documents"),
42 uploads: files.join("uploads"),
43 files,
44 root,
45 })
46 }
47
48 pub fn root(&self) -> &Path {
49 &self.root
50 }
51
52 pub fn files(&self) -> &Path {
53 &self.files
54 }
55
56 pub fn css(&self) -> &Path {
57 &self.css
58 }
59
60 pub fn js(&self) -> &Path {
61 &self.js
62 }
63
64 pub fn fonts(&self) -> &Path {
65 &self.fonts
66 }
67
68 pub fn images(&self) -> &Path {
69 &self.images
70 }
71
72 pub fn generated_images(&self) -> &Path {
73 &self.generated_images
74 }
75
76 pub fn logos(&self) -> &Path {
77 &self.logos
78 }
79
80 pub fn audio(&self) -> &Path {
81 &self.audio
82 }
83
84 pub fn video(&self) -> &Path {
85 &self.video
86 }
87
88 pub fn documents(&self) -> &Path {
89 &self.documents
90 }
91
92 pub fn uploads(&self) -> &Path {
93 &self.uploads
94 }
95}