pub struct PathManager {
base_dir: PathBuf,
subcog_dir: PathBuf,
}Expand description
Manages storage paths for subcog backends.
PathManager provides a centralized way to construct paths for:
SQLiteindex databases- Vector similarity indices
- The user-level data directory
Project scope uses the user-level data directory with project facets.
Fields§
§base_dir: PathBufBase directory for storage (user data dir).
subcog_dir: PathBufThe subcog data directory (same as base dir).
Implementations§
Source§impl PathManager
impl PathManager
Sourcepub fn for_repo(_repo_root: impl AsRef<Path>) -> Self
pub fn for_repo(_repo_root: impl AsRef<Path>) -> Self
Creates a PathManager for repository-scoped storage.
Storage paths will be within the user data directory. Falls back to a temporary user-level directory if the user data dir cannot be resolved.
§Arguments
repo_root- Path to the git repository root
§Examples
let manager = PathManager::for_repo(Path::new("/home/user/project"));
// Uses user data directory, not repo-local storageSourcepub fn for_user(user_data_dir: impl AsRef<Path>) -> Self
pub fn for_user(user_data_dir: impl AsRef<Path>) -> Self
Creates a PathManager for user-scoped storage.
Storage paths will be directly within the user data directory
(no .subcog subdirectory).
§Arguments
user_data_dir- Platform-specific user data directory
§Examples
let manager = PathManager::for_user(Path::new("/home/user/.local/share/subcog"));
assert_eq!(manager.subcog_dir(), Path::new("/home/user/.local/share/subcog"));Sourcepub fn subcog_dir(&self) -> &Path
pub fn subcog_dir(&self) -> &Path
Returns the subcog data directory.
For project/user scope: {user_data_dir} (same as base)
Sourcepub fn index_path(&self) -> PathBuf
pub fn index_path(&self) -> PathBuf
Sourcepub fn vector_path(&self) -> PathBuf
pub fn vector_path(&self) -> PathBuf
Sourcepub fn graph_path(&self) -> PathBuf
pub fn graph_path(&self) -> PathBuf
Sourcepub fn ensure_subcog_dir(&self) -> Result<()>
pub fn ensure_subcog_dir(&self) -> Result<()>
Ensures the subcog directory exists.
Creates the directory and any necessary parent directories.
§Errors
Returns an error if directory creation fails due to permissions or other filesystem issues.
§Examples
let manager = PathManager::for_repo(Path::new("/path/to/repo"));
manager.ensure_subcog_dir()?;
// Now safe to create backends at manager.index_path() and manager.vector_path()Trait Implementations§
Source§impl Clone for PathManager
impl Clone for PathManager
Source§fn clone(&self) -> PathManager
fn clone(&self) -> PathManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PathManager
impl RefUnwindSafe for PathManager
impl Send for PathManager
impl Sync for PathManager
impl Unpin for PathManager
impl UnwindSafe for PathManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].