Skip to main content

SourceTree

Trait SourceTree 

Source
pub trait SourceTree {
    // Required methods
    fn is_directory(&self, path: &Path) -> bool;
    fn entries(&self, path: &Path) -> Result<Vec<PathBuf>, String>;
    fn read_text(&self, path: &Path) -> Result<String, String>;
}
Expand description

The filesystem facts a recursive source walk needs. 递归源码遍历所需的文件系统事实。

The kernel owns the algorithm and never touches the filesystem; an execution surface supplies these three operations. 内核拥有算法且从不接触文件系统;三项操作由执行面提供。

Required Methods§

Source

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

Whether path names a directory; the walk recurses only when this is true. path 是否为目录;仅当为真时遍历才递归进入。

Source

fn entries(&self, path: &Path) -> Result<Vec<PathBuf>, String>

The direct entries of path; an error aborts the whole walk. path 的直接条目;返回错误会中止整次遍历。

Source

fn read_text(&self, path: &Path) -> Result<String, String>

Read a .rs file when the keep callback asks for its text; an error skips only that file. 当 keep 回调索取文本时读取 .rs 文件;返回错误只跳过该文件。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§