Skip to main content

Workspace

Trait Workspace 

Source
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§

Source

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.

Source

fn read(&self, path: &RelPath) -> FsResult<String>

Reads a UTF-8 file, following links.

Source

fn write(&self, path: &RelPath, contents: &str) -> FsResult<()>

Writes a UTF-8 file, creating parent directories as needed.

Source

fn create_dir_all(&self, path: &RelPath) -> FsResult<()>

Creates a directory and all missing parents.

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.

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.

Source

fn remove_file(&self, path: &RelPath) -> FsResult<()>

Removes a regular file.

Source

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.

Source

fn rename(&self, from: &RelPath, to: &RelPath) -> FsResult<()>

Moves an entry, creating the destination’s parents as needed.

Source

fn is_empty_dir(&self, path: &RelPath) -> FsResult<bool>

Whether path is a directory containing no entries.

Source

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".

Implementors§