Trait WorkspaceDirectory

Source
pub trait WorkspaceDirectory: WorkspaceEntry {
    // Required methods
    fn my_workspace(&self) -> &Workspace;
    fn rel_path(&self) -> PathBuf;
    fn file(&self, file: &str) -> Result<RegularFile, WorkspaceError>;
    fn dir(&self, name: &str) -> Result<Dir<'_>, WorkspaceError>;
    fn protected_dir(&self, name: &str) -> Result<Dir<'_>, WorkspaceError>;
    fn protected_file(&self, name: &str) -> Result<RegularFile, WorkspaceError>;

    // Provided methods
    fn new_workspace<P>(&self, path: P) -> Workspace
       where P: AsRef<Path> { ... }
    fn absolute_path(&self) -> PathBuf { ... }
    fn is_protected(&self, path: &Path) -> bool { ... }
}

Required Methods§

Source

fn my_workspace(&self) -> &Workspace

Gets the workspace this directory is part of.

Source

fn rel_path(&self) -> PathBuf

Gets the path of this directory relative to the workspace.

Source

fn file(&self, file: &str) -> Result<RegularFile, WorkspaceError>

Creates a file within this directory

§Error

Will panic if .. paths are present at root of workspace

Source

fn dir(&self, name: &str) -> Result<Dir<'_>, WorkspaceError>

Creates a directory within this directory

§Error

Will panic if .. paths are present at root of workspace

Source

fn protected_dir(&self, name: &str) -> Result<Dir<'_>, WorkspaceError>

Creates a protected directory in this directory

§Error

Will panic if .. paths are present at root of workspace

Source

fn protected_file(&self, name: &str) -> Result<RegularFile, WorkspaceError>

Creates a protected file in this directory

§Error

Will panic if .. paths are present at root of workspace

Provided Methods§

Source

fn new_workspace<P>(&self, path: P) -> Workspace
where P: AsRef<Path>,

Create a workspace that’s relative to this workspace. Shares proteced paths with parent workspace and other created workspaces.

§Error

Will panic if any .. paths are present.

Source

fn absolute_path(&self) -> PathBuf

Gets the absolute path of this directory

Source

fn is_protected(&self, path: &Path) -> bool

Checks if a path is protected.

The path should be a relative path from the member.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§