Skip to main content

FilterTree

Trait FilterTree 

Source
pub trait FilterTree {
    // Required methods
    fn filter_by_patterns<'a>(
        &'a self,
        tree: &'a Tree<'a>,
        patterns: &[&str],
    ) -> Result<Tree<'a>, Error>;
    fn filter_by_attributes<'a>(
        &'a self,
        tree: &'a Tree<'a>,
        attributes: &[&str],
    ) -> Result<Tree<'a>, Error>;
    fn filter_by_predicate<'a, F>(
        &'a self,
        tree: &'a Tree<'a>,
        predicate: F,
    ) -> Result<Tree<'a>, Error>
       where F: Fn(&Repository, &Path) -> bool;
}

Required Methods§

Source

fn filter_by_patterns<'a>( &'a self, tree: &'a Tree<'a>, patterns: &[&str], ) -> Result<Tree<'a>, Error>

Filters tree entries by gitattributes-style patterns and returns a new tree with contents filtered through the provided patterns. Recursively walks the tree and matches patterns against full paths from the tree root.

The patterns type is an array of string slices and not a glob type because Git has specific glob syntax that differs from standard shell syntax.

Source

fn filter_by_attributes<'a>( &'a self, tree: &'a Tree<'a>, attributes: &[&str], ) -> Result<Tree<'a>, Error>

Filters tree entries by gitattributes and returns a new tree with contents filtered. Recursively walks the tree and matches attributes against full paths from the tree root.

The attributes type is an array of string slices. For attributes which have values, not simply set or unset, use typical .gitattributes syntax.

Source

fn filter_by_predicate<'a, F>( &'a self, tree: &'a Tree<'a>, predicate: F, ) -> Result<Tree<'a>, Error>
where F: Fn(&Repository, &Path) -> bool,

Filters tree entries using an arbitrary predicate and returns a new tree. Recursively walks the tree; the predicate is called for each blob entry with the repository and the entry’s full path relative to the tree root. Subtrees are retained as long as at least one descendant matches.

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§