pub struct PathResolver { /* private fields */ }Expand description
Builder-style resolver over the opencode data directory.
Implementations§
Source§impl PathResolver
impl PathResolver
pub fn new() -> Self
pub fn with_home<P: Into<PathBuf>>(self, home: P) -> Self
Sourcepub fn with_data_dir<P: Into<PathBuf>>(self, data_dir: P) -> Self
pub fn with_data_dir<P: Into<PathBuf>>(self, data_dir: P) -> Self
Override the data directory directly (defaults to
$XDG_DATA_HOME/opencode or ~/.local/share/opencode).
pub fn home_dir(&self) -> Result<&Path>
pub fn data_dir(&self) -> Result<PathBuf>
pub fn db_path(&self) -> Result<PathBuf>
pub fn snapshot_root(&self) -> Result<PathBuf>
pub fn log_dir(&self) -> Result<PathBuf>
Sourcepub fn snapshot_gitdir(
&self,
project_id: &str,
worktree: &Path,
) -> Result<PathBuf>
pub fn snapshot_gitdir( &self, project_id: &str, worktree: &Path, ) -> Result<PathBuf>
The bare git repository that backs snapshots for a given
(project_id, worktree) pair.
opencode has used two layouts over its lifetime:
- Current:
snapshot/<project-id>/<sha1(worktree)>/— one gitdir per(project, worktree)pair so forked worktrees get isolated snapshot stores. - Older:
snapshot/<project-id>/— a single gitdir per project regardless of worktree.
Returns the first candidate that exists. If neither exists,
returns the current-layout path (so the caller’s subsequent
git2::Repository::open will produce a clean NotFound error).
pub fn exists(&self) -> bool
pub fn db_exists(&self) -> bool
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