Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate attributes

Crate attributes 

Source
Available on crate feature attributes only.
Expand description

Parse .gitattribute files and provide utilities to match against them.

§Examples

use gix_attributes::search::{MetadataCollection, Outcome};
use gix_glob::pattern::Case;

let mut search = gix_attributes::Search::default();
let mut collection = MetadataCollection::default();
search.add_patterns_buffer(
    b"*.sh text eol=lf",
    "<memory>".into(),
    None,
    &mut collection,
    true,
);

let mut out = Outcome::default();
out.initialize_with_selection(&collection, ["text", "eol"]);
assert!(search.pattern_matching_relative_path("script.sh".into(), Case::Sensitive, Some(false), &mut out));

let assignments = out
    .iter_selected()
    .map(|m| m.assignment.to_string())
    .collect::<Vec<_>>();
assert_eq!(assignments, vec!["text", "eol=lf"]);

§Feature Flags

Modules§

glob
Provide glob Patterns for matching against paths or anything else.
name
parse
search
state

Structs§

Assignment
Name an attribute and describe it’s assigned state.
AssignmentRef
Holds validated attribute data as a reference
Name
Represents a validated attribute name
NameRef
Holds a validated attribute name as a reference
Search
A grouping of lists of patterns while possibly keeping associated to their base path in order to find matches.

Enums§

Source
A list of known global sources for git attribute files in order of ascending precedence.
State
The state an attribute can be in, owning the value.
StateRef
The state an attribute can be in, referencing the value.

Functions§

parse
Parse attribute assignments line by line from bytes, and fail the operation on error.