pub trait Workspace {
// Required methods
fn probe(&self, path: &RelPath) -> FsResult<Option<Entry>>;
fn read(&self, path: &RelPath) -> FsResult<String>;
fn write(&self, path: &RelPath, contents: &str) -> FsResult<()>;
fn create_dir_all(&self, path: &RelPath) -> FsResult<()>;
fn link(
&self,
via: Via,
node: NodeKind,
canonical: &RelPath,
target: &RelPath,
) -> FsResult<()>;
fn remove_link(&self, path: &RelPath, node: NodeKind) -> FsResult<()>;
fn remove_file(&self, path: &RelPath) -> FsResult<()>;
fn remove_empty_dir(&self, path: &RelPath) -> FsResult<()>;
fn rename(&self, from: &RelPath, to: &RelPath) -> FsResult<()>;
fn is_empty_dir(&self, path: &RelPath) -> FsResult<bool>;
fn support(&self) -> LinkSupport;
}Expand description
A rooted view of a workspace directory.
Required Methods§
Sourcefn probe(&self, path: &RelPath) -> FsResult<Option<Entry>>
fn probe(&self, path: &RelPath) -> FsResult<Option<Entry>>
Inspects an entry without following a trailing link.
Returns None when nothing exists at path. A dangling link still
returns Some, because for our purposes the link itself is the entry
that occupies the path.
Sourcefn write(&self, path: &RelPath, contents: &str) -> FsResult<()>
fn write(&self, path: &RelPath, contents: &str) -> FsResult<()>
Writes a UTF-8 file, creating parent directories as needed.
Sourcefn create_dir_all(&self, path: &RelPath) -> FsResult<()>
fn create_dir_all(&self, path: &RelPath) -> FsResult<()>
Creates a directory and all missing parents.
Sourcefn link(
&self,
via: Via,
node: NodeKind,
canonical: &RelPath,
target: &RelPath,
) -> FsResult<()>
fn link( &self, via: Via, node: NodeKind, canonical: &RelPath, target: &RelPath, ) -> FsResult<()>
Creates a link at target resolving to canonical, creating target’s
parent directories as needed.
The adapter decides how canonical is encoded: symlinks store a
workspace-relative path so the workspace stays movable, while Windows
junctions require an absolute one.
Sourcefn remove_link(&self, path: &RelPath, node: NodeKind) -> FsResult<()>
fn remove_link(&self, path: &RelPath, node: NodeKind) -> FsResult<()>
Removes a link, never recursing into its contents.
Implementations must refuse to delete a concrete directory: destroying user content is the one failure mode this tool cannot afford.
Sourcefn remove_file(&self, path: &RelPath) -> FsResult<()>
fn remove_file(&self, path: &RelPath) -> FsResult<()>
Removes a regular file.
Sourcefn remove_empty_dir(&self, path: &RelPath) -> FsResult<()>
fn remove_empty_dir(&self, path: &RelPath) -> FsResult<()>
Removes a directory, failing if it is not empty.
Deliberately never recursive. Adoption needs to clear an empty canonical directory before moving content onto it; nothing in agentlink has a reason to delete a populated one.
Sourcefn rename(&self, from: &RelPath, to: &RelPath) -> FsResult<()>
fn rename(&self, from: &RelPath, to: &RelPath) -> FsResult<()>
Moves an entry, creating the destination’s parents as needed.
Sourcefn is_empty_dir(&self, path: &RelPath) -> FsResult<bool>
fn is_empty_dir(&self, path: &RelPath) -> FsResult<bool>
Whether path is a directory containing no entries.
Sourcefn support(&self) -> LinkSupport
fn support(&self) -> LinkSupport
Which link primitives this host currently permits.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".