Crate relay_pattern

Source
Expand description

A glob like pattern used throught Relay and its APIs.

§Behaviour

A pattern is similar to a glob but without support for brace expansions and without any support for filesystem specific behaviour like platform dependent separators and file extension matching.

By default a Pattern does not support any separator characters. For example * usually only matches up to the next path separator (often platform dependent), in a Pattern * matches all characters. Optional support for a single separator character is available.

The empty glob "" never matches.

§Syntax

Basic glob like syntax is supported with Unix style negations.

  • ? matches any single character.
  • * matches any number of any characters, including none.
  • [abc] matches one character in the given bracket.
  • [!abc] matches one character that is not in the given bracket.
  • [a-z] matches one character in the given range.
  • [!a-z] matches one character that is not in the given range.
  • {a,b} matches any pattern within the alternation group.
  • \ escapes any of the above special characters and treats it as a literal.

§Complexity

Patterns can be limited to a maximum complexity using PatternBuilder::max_complexity. Complexity of a pattern is calculated by the amount of possible combinations created with alternations.

For example, the pattern {foo,bar} has a complexity of 2, the pattern {foo,bar}/{*.html,*.js,*.css} has a complexity of 2 * 3.

For untrusted user input it is highly recommended to limit the maximum complexity.

Structs§

CaseInsensitive
The default pattern but with case insensitive matching.
DefaultPatternConfig
The default pattern.
Error
Pattern parsing error.
Pattern
Pattern represents a successfully parsed Relay pattern.
PatternBuilder
A builder for a Pattern.
Patterns
A collection of Patterns sharing the same configuration.
PatternsBuilder
A builder for a collection of Patterns.
PatternsBuilderConfigured
A PatternsBuilder with all options configured.
TypedPattern
A Pattern with compile time encoded PatternConfig.
TypedPatterns
Patterns with a compile time configured PatternConfig.
TypedPatternsBuilder

Traits§

PatternConfig
Compile time configuration for a TypedPattern.