pub struct Workspace {
pub root: PathBuf,
pub canonical_root: PathBuf,
pub repo_name: String,
}Expand description
Represents a bound workspace session.
Fields§
§root: PathBuf§canonical_root: PathBuf§repo_name: StringImplementations§
Source§impl Workspace
impl Workspace
Sourcepub fn discover(start_path: Option<&Path>) -> Result<Self, WorkspaceError>
pub fn discover(start_path: Option<&Path>) -> Result<Self, WorkspaceError>
Discover and bind a workspace from an optional path, falling back to CWD and upward traversal.
Sourcepub fn new(root: PathBuf) -> Self
pub fn new(root: PathBuf) -> Self
Create workspace binding directly for a known root directory.
Sourcepub fn find_workspace_root(start: &Path) -> Result<PathBuf, WorkspaceError>
pub fn find_workspace_root(start: &Path) -> Result<PathBuf, WorkspaceError>
Find root by searching upwards for .git, .code-kb, or workspace markers.
Sourcepub fn from_project_root(input: &str) -> Result<Workspace, WorkspaceError>
pub fn from_project_root(input: &str) -> Result<Workspace, WorkspaceError>
Resolves the project_root of a tool call: an absolute path or file:// URI of the
project or git worktree, or of any folder or file inside it.
Sourcepub fn nested_project_root(&self, path: &Path) -> Option<PathBuf>
pub fn nested_project_root(&self, path: &Path) -> Option<PathBuf>
For an absolute path inside this workspace, returns the nearest folder from the path up to
the root (the root excluded) that holds .git: a nested git worktree or submodule.
Sourcepub fn resolve_path(
&self,
input: &Path,
) -> Result<(PathBuf, String), WorkspaceError>
pub fn resolve_path( &self, input: &Path, ) -> Result<(PathBuf, String), WorkspaceError>
Resolves an input path (relative, absolute, or file:// URI) to a canonical absolute path and relative path.
Sourcepub fn relativize_filter(&self, filter: &str) -> String
pub fn relativize_filter(&self, filter: &str) -> String
Relativizes a path filter string (which may be absolute, file:// URI, or relative) against this workspace root into a forward-slash relative path suitable for SQLite queries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Workspace
impl RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl UnsafeUnpin for Workspace
impl UnwindSafe for Workspace
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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