pub struct StorageLayout { /* private fields */ }Expand description
Computes all Synwire storage paths for a given product name.
§Configuration hierarchy
SYNWIRE_DATA_DIR/SYNWIRE_CACHE_DIRenvironment variables- Programmatic override via
StorageLayout::with_root - Project-local
.<product>/config.json - Platform default (
directories::BaseDirs)
Implementations§
Source§impl StorageLayout
impl StorageLayout
Sourcepub fn new(product_name: impl Into<String>) -> Result<Self, StorageError>
pub fn new(product_name: impl Into<String>) -> Result<Self, StorageError>
Create a new layout for the given product name, respecting environment variables and platform defaults.
§Errors
Returns StorageError::NotWritable if the platform provides no
usable base directories.
Sourcepub fn with_root(
root: impl AsRef<Path>,
product_name: impl Into<String>,
) -> Self
pub fn with_root( root: impl AsRef<Path>, product_name: impl Into<String>, ) -> Self
Create a layout rooted at a custom base directory (for testing or
explicit overrides). Data is stored under <root>/data/<product> and
caches under <root>/cache/<product>.
Sourcepub fn with_config(self, config: &StorageConfig) -> Self
pub fn with_config(self, config: &StorageConfig) -> Self
Apply a StorageConfig override on top of this layout.
Sourcepub fn cache_home(&self) -> &Path
pub fn cache_home(&self) -> &Path
Root cache directory for this product.
Sourcepub fn product_name(&self) -> &str
pub fn product_name(&self) -> &str
Product name.
Sourcepub fn session_db(&self, session_id: &str) -> PathBuf
pub fn session_db(&self, session_id: &str) -> PathBuf
SQLite checkpoint database for a given session ID.
Sourcepub fn experience_db(&self, worktree: &WorktreeId) -> PathBuf
pub fn experience_db(&self, worktree: &WorktreeId) -> PathBuf
Per-worktree experience pool database.
Sourcepub fn skills_dir(&self) -> PathBuf
pub fn skills_dir(&self) -> PathBuf
Global agent skills directory.
Sourcepub fn daemon_pid_file(&self) -> PathBuf
pub fn daemon_pid_file(&self) -> PathBuf
Daemon PID file path.
Sourcepub fn daemon_socket(&self) -> PathBuf
pub fn daemon_socket(&self) -> PathBuf
Daemon Unix domain socket path.
Sourcepub fn global_experience_db(&self) -> PathBuf
pub fn global_experience_db(&self) -> PathBuf
Global cross-project experience database.
Sourcepub fn global_dependency_db(&self) -> PathBuf
pub fn global_dependency_db(&self) -> PathBuf
Global cross-project dependency index database.
Sourcepub fn global_registry(&self) -> PathBuf
pub fn global_registry(&self) -> PathBuf
Global project registry JSON file.
Sourcepub fn global_config(&self) -> PathBuf
pub fn global_config(&self) -> PathBuf
Global product config JSON file.
Sourcepub fn index_cache(&self, worktree: &WorktreeId) -> PathBuf
pub fn index_cache(&self, worktree: &WorktreeId) -> PathBuf
Vector + BM25 index cache directory for a worktree.
Sourcepub fn graph_dir(&self, worktree: &WorktreeId) -> PathBuf
pub fn graph_dir(&self, worktree: &WorktreeId) -> PathBuf
Code dependency graph directory for a worktree.
Sourcepub fn communities_dir(&self, worktree: &WorktreeId) -> PathBuf
pub fn communities_dir(&self, worktree: &WorktreeId) -> PathBuf
Community detection state directory for a worktree.
Sourcepub fn lsp_cache(&self, worktree: &WorktreeId) -> PathBuf
pub fn lsp_cache(&self, worktree: &WorktreeId) -> PathBuf
LSP server cache directory for a worktree.
Sourcepub fn models_cache(&self) -> PathBuf
pub fn models_cache(&self) -> PathBuf
Embedding model download cache.
Sourcepub fn repos_cache(&self) -> PathBuf
pub fn repos_cache(&self) -> PathBuf
Root directory for cloned repositories.
Sourcepub fn repo_cache(&self, owner: &str, repo: &str) -> PathBuf
pub fn repo_cache(&self, owner: &str, repo: &str) -> PathBuf
Directory for a specific cloned repository.
Sourcepub fn repo_gc(&self, max_age_days: u64) -> Result<Vec<PathBuf>, StorageError>
pub fn repo_gc(&self, max_age_days: u64) -> Result<Vec<PathBuf>, StorageError>
Remove cached repositories not accessed within max_age_days.
Returns the list of directories removed. Skips repositories that are currently mounted (not implemented in v0.1).
§Errors
Returns StorageError::Io if a directory entry cannot be read or
removed.
Sourcepub fn project_skills_dirname(&self) -> &str
pub fn project_skills_dirname(&self) -> &str
Name of the project-local skills directory (e.g., .synwire).
Sourcepub fn ensure_dir(&self, path: &Path) -> Result<(), StorageError>
pub fn ensure_dir(&self, path: &Path) -> Result<(), StorageError>
Ensure the given directory exists, creating it (and all parents) as
needed. Sets permissions to 0o700 on Unix.
§Errors
Returns StorageError::Io if the directory cannot be created.
Sourcepub fn load_project_config(
&self,
project_root: &Path,
) -> Result<Option<StorageConfig>, StorageError>
pub fn load_project_config( &self, project_root: &Path, ) -> Result<Option<StorageConfig>, StorageError>
Load a per-project config from <project_root>/.<product>/config.json.
Returns Ok(None) if the file does not exist.
§Errors
Returns StorageError::InvalidConfig if the file exists but is not
valid JSON.
Trait Implementations§
Source§impl Clone for StorageLayout
impl Clone for StorageLayout
Source§fn clone(&self) -> StorageLayout
fn clone(&self) -> StorageLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more