pub struct PathResolver { /* private fields */ }Expand description
Resolves the Pi sessions directory and its project subdirectories.
Implementations§
Source§impl PathResolver
impl PathResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Default resolver: $HOME/.pi/agent/sessions/, falling back to
./.pi/agent/sessions when no home directory is available.
Sourcepub fn with_home(self, home: impl AsRef<Path>) -> Self
pub fn with_home(self, home: impl AsRef<Path>) -> Self
Override the home directory (useful for tests). Recomputes sessions_dir unless an explicit sessions-dir override is in effect.
Sourcepub fn with_sessions_dir(self, dir: impl AsRef<Path>) -> Self
pub fn with_sessions_dir(self, dir: impl AsRef<Path>) -> Self
Override the sessions base directory directly.
Sourcepub fn sessions_dir(&self) -> &Path
pub fn sessions_dir(&self) -> &Path
The resolved sessions directory (.../sessions/).
Sourcepub fn project_dir(&self, cwd: &str) -> PathBuf
pub fn project_dir(&self, cwd: &str) -> PathBuf
Project directory for a given cwd.
Sourcepub fn encode_cwd(&self, cwd: &str) -> String
pub fn encode_cwd(&self, cwd: &str) -> String
Return the project cwd → directory-name encoding for cwd.
Sourcepub fn decode_project_dir(&self, dir_name: &str) -> String
pub fn decode_project_dir(&self, dir_name: &str) -> String
Return the cwd decoded from a project directory name.
Sourcepub fn list_projects(&self) -> Result<Vec<String>>
pub fn list_projects(&self) -> Result<Vec<String>>
Enumerate project directories that exist on disk. Returns decoded cwd strings, sorted ascending. Missing sessions_dir returns an empty vec rather than an error.
Trait Implementations§
Source§impl Clone for PathResolver
impl Clone for PathResolver
Source§fn clone(&self) -> PathResolver
fn clone(&self) -> PathResolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PathResolver
impl Debug for PathResolver
Auto Trait Implementations§
impl Freeze for PathResolver
impl RefUnwindSafe for PathResolver
impl Send for PathResolver
impl Sync for PathResolver
impl Unpin for PathResolver
impl UnsafeUnpin for PathResolver
impl UnwindSafe for PathResolver
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
Mutably borrows from an owned value. Read more