glob

面向 MoonBit 的可复用通配符路径匹配与文件检索库,支持 Wasm、JS 与 Native 目标。

glob
pattern-matching
wildcard
filepath
path
moon add Lxxbv/glob@0.2.6
Download zip
Author
Version
0.2.6
License
Apache-2.0
Last updated
2 days ago
Downloads
29

Dependencies

README

#Lxxbv/glob

Lxxbv/glob 是 MoonBit 的跨平台 Glob 路径匹配和文件检索库。

它提供:

  • compile_pattern / CompiledPattern:编译一次,循环复用;
  • glob_with_options:文件系统搜索、隐藏项、深度和排序控制;
  • GlobQuery / GlobPipeline:组合 include/exclude、限制和报告;
  • GlobRules:类似 .gitignore 的规则解析;
  • PathIndex:内存路径索引;
  • explain_patternPatternCache 和确定性 benchmark workload。

基础用法:

let pattern = @glob.compile_pattern("src/**/*.mbt")?
let paths = ["src/main.mbt", "src/core/parser.mbt", "README.md"]
let matched = @glob.filter_compiled_patterns([pattern], paths)

文件系统用法:

let options = @glob.GlobOptions::default().files_only().sorted()
let files = @glob.glob_with_options(".", "**/*.mbt", options)?

CLI 用法:

moon run cmd/main "**/*.mbt" moon run cmd/main "src/**/*.mbt" "src"

完整语义、错误处理、Windows 安装、基准数据、许可证和 CI 验收命令请阅读 README.md

#
AST

pub enum AST {
Text(String)
Question
Star
GlobStar
CharClass(Bool, Array[CharClassElement])
Brace(Array[Array[AST]])
Seq(Array[AST])
} derive(Eq,
Debug
)

Represents the Abstract Syntax Tree (AST) of a Glob pattern.

#
CacheError

pub enum CacheError {
InvalidCapacity
} derive(Eq,
Debug
)

impl Show for CacheError

#
CacheStats

pub(all) struct CacheStats {
entries : Int
capacity : Int
hits : Int
misses : Int
evictions : Int
} derive(Eq,
Debug
)

#
CachedPattern

pub(all) struct CachedPattern {
source : String
compiled : CompiledPattern
hits : Int
} derive(Eq,
Debug
)

#
CharClassElement

pub enum CharClassElement {
Single(Char)
Range(Char, Char)
} derive(Eq,
Debug
)

Represents a component inside a character class [...].

#
CompiledPattern

pub(all) struct CompiledPattern {
source : String
ast : AST
stats : PatternStats
prefix : String
separators : Int
recursive : Bool
segments : Int
} derive(Eq,
Debug
)

A reusable compiled glob pattern with stable structural metadata.

#
CompiledPattern::ast

Returns the compiled syntax tree for advanced callers.

#
CompiledPattern::estimated_branches

fn CompiledPattern::estimated_branches(self : CompiledPattern) -> Int

Estimates the number of matching branches exposed by the syntax tree.

#
CompiledPattern::has_magic

fn CompiledPattern::has_magic(self : CompiledPattern) -> Bool

Returns true when this handle has at least one wildcard construct.

#
CompiledPattern::has_recursive_wildcard

fn CompiledPattern::has_recursive_wildcard(self : CompiledPattern) -> Bool

Returns whether the pattern contains the recursive \**\\ construct.

#
CompiledPattern::is_literal

fn CompiledPattern::is_literal(self : CompiledPattern) -> Bool

Returns true when this handle is a literal-only pattern.

#
CompiledPattern::literal_prefix

fn CompiledPattern::literal_prefix(self : CompiledPattern) -> String

Returns the literal prefix before the first wildcard.

#
CompiledPattern::matches

fn CompiledPattern::matches(self : CompiledPattern, path : String) -> Bool

Matches one path without reparsing the source pattern.

#
CompiledPattern::pattern

fn CompiledPattern::pattern(self : CompiledPattern) -> String

Returns the original source pattern.

#
CompiledPattern::segment_count

fn CompiledPattern::segment_count(self : CompiledPattern) -> Int

Returns the number of non-empty source path components.

#
CompiledPattern::separator_count

fn CompiledPattern::separator_count(self : CompiledPattern) -> Int

Returns the number of path separators in the source pattern.

#
CompiledPattern::stats

Returns structural pattern statistics captured at compile time.

#
CompiledPattern::summary

fn CompiledPattern::summary(self : CompiledPattern) -> String

Returns a compact, deterministic metadata summary useful in logs.

#
GlobError

pub enum GlobError {
UnclosedBrace
UnclosedBracket
InvalidRange
EmptyPattern
UnexpectedComma
UnexpectedClosingBrace
UnexpectedToken(String)
InvalidMaxDepth
NonLiteralSegment
FilesystemError(String)
} derive(Eq,
Debug
)

Represents errors that can occur during glob parsing.
impl Show for GlobError

#
GlobOptions

pub(all) struct GlobOptions {
include_files : Bool
include_directories : Bool
include_hidden : Bool
max_depth : Int?
sort_results : Bool
} derive(Eq,
Debug
)

Controls which filesystem entries are returned by glob_with_options.

#
GlobOptions::default

fn GlobOptions::default() -> GlobOptions

Creates options compatible with the original glob behavior.

#
GlobOptions::directories_only

fn GlobOptions::directories_only(self : GlobOptions) -> GlobOptions

Returns options that include directories but not files.

#
GlobOptions::files_only

fn GlobOptions::files_only(self : GlobOptions) -> GlobOptions

Returns options that include files but not directories.

#
GlobOptions::sorted

fn GlobOptions::sorted(self : GlobOptions) -> GlobOptions

Returns options with deterministic lexicographic output ordering.

#
GlobOptions::with_max_depth

fn GlobOptions::with_max_depth(self : GlobOptions, depth : Int) -> Result[GlobOptions, GlobError]

Limits traversal to entries at or below the given relative depth.

#
GlobOptions::without_hidden

fn GlobOptions::without_hidden(self : GlobOptions) -> GlobOptions

Returns options that skip hidden path components.

#
GlobPipeline

pub(all) struct GlobPipeline {
cache : PatternCache
includes : Array[String]
excludes : Array[String]
options : GlobOptions
limit : Int?
} derive(Eq,
Debug
)

#
GlobPipeline::exclude_count

fn GlobPipeline::exclude_count(self : GlobPipeline) -> Int

#
GlobPipeline::exclude_pattern

fn GlobPipeline::exclude_pattern(self : GlobPipeline, pattern : String) -> GlobPipeline

#
GlobPipeline::include_count

fn GlobPipeline::include_count(self : GlobPipeline) -> Int

#
GlobPipeline::include_pattern

fn GlobPipeline::include_pattern(self : GlobPipeline, pattern : String) -> GlobPipeline

#
GlobPipeline::new

fn GlobPipeline::new(cache_capacity : Int) -> Result[GlobPipeline, CacheError]

Creates a pipeline with a bounded compiled-pattern cache.

#
GlobPipeline::run

fn GlobPipeline::run(self : GlobPipeline, paths : Array[String]) -> Result[PipelineReport, GlobError]

Runs a pipeline and returns only the report for one-shot callers.

#
GlobPipeline::run_with_cache

fn GlobPipeline::run_with_cache(self : GlobPipeline, paths : Array[String]) -> Result[(GlobPipeline, PipelineReport), GlobError]

Runs include/exclude matching once over a candidate path array.

#
GlobPipeline::sorted

fn GlobPipeline::sorted(self : GlobPipeline) -> GlobPipeline

#
GlobPipeline::with_limit

fn GlobPipeline::with_limit(self : GlobPipeline, limit : Int) -> Result[GlobPipeline, PipelineError]

#
GlobPipeline::with_options

fn GlobPipeline::with_options(self : GlobPipeline, options : GlobOptions) -> GlobPipeline

#
GlobPipeline::without_hidden

fn GlobPipeline::without_hidden(self : GlobPipeline) -> GlobPipeline

#
GlobQuery

pub(all) struct GlobQuery {
includes : Array[CompiledPattern]
excludes : Array[CompiledPattern]
options : GlobOptions
min_depth : Int
limit : Int?
} derive(Eq,
Debug
)

A reusable query with include rules, exclude rules, and result policies.

#
GlobQuery::directories_only

fn GlobQuery::directories_only(self : GlobQuery) -> GlobQuery

Restricts results to directories when querying a filesystem.

#
GlobQuery::exclude_count

fn GlobQuery::exclude_count(self : GlobQuery) -> Int

Returns the number of exclude rules.

#
GlobQuery::exclude_pattern

fn GlobQuery::exclude_pattern(self : GlobQuery, pattern : String) -> Result[GlobQuery, GlobError]

Adds an exclude pattern. Exclusions always take precedence.

#
GlobQuery::execute_filesystem

fn GlobQuery::execute_filesystem(self : GlobQuery, dir : String) -> Result[QueryReport, GlobError]

Executes the query against all traversable entries under a directory.

#
GlobQuery::execute_index

fn GlobQuery::execute_index(self : GlobQuery, index : PathIndex) -> QueryReport

Executes a query against an in-memory index without discarding entry kinds. This is useful for build tools that refresh a path index once and issue many queries without repeatedly touching the filesystem.

#
GlobQuery::execute_paths

fn GlobQuery::execute_paths(self : GlobQuery, paths : Array[String]) -> QueryReport

Executes this query against a caller-provided path list.

#
GlobQuery::files_only

fn GlobQuery::files_only(self : GlobQuery) -> GlobQuery

Restricts results to files when querying a filesystem.

#
GlobQuery::include_count

fn GlobQuery::include_count(self : GlobQuery) -> Int

Returns the number of include rules.

#
GlobQuery::include_pattern

fn GlobQuery::include_pattern(self : GlobQuery, pattern : String) -> Result[GlobQuery, GlobError]

Adds an include pattern. Multiple includes use OR semantics.

#
GlobQuery::matches

fn GlobQuery::matches(self : GlobQuery, path : String) -> Bool

Tests a normalized or platform-specific path against this query.

#
GlobQuery::new

fn GlobQuery::new() -> GlobQuery

#
GlobQuery::sorted

fn GlobQuery::sorted(self : GlobQuery) -> GlobQuery

Enables deterministic result ordering.

#
GlobQuery::summary

fn GlobQuery::summary(self : GlobQuery) -> String

Returns a concise configuration summary for logs and diagnostics.

#
GlobQuery::with_limit

fn GlobQuery::with_limit(self : GlobQuery, limit : Int) -> Result[GlobQuery, GlobError]

Limits the number of returned paths.

#
GlobQuery::with_min_depth

fn GlobQuery::with_min_depth(self : GlobQuery, depth : Int) -> Result[GlobQuery, GlobError]

Requires paths to have at least the given number of components.

#
GlobQuery::with_options

fn GlobQuery::with_options(self : GlobQuery, options : GlobOptions) -> GlobQuery

Replaces traversal and result options.

#
GlobQuery::without_hidden

fn GlobQuery::without_hidden(self : GlobQuery) -> GlobQuery

Excludes hidden components from the result.

#
GlobRule

pub(all) struct GlobRule {
source : String
pattern : CompiledPattern
action : RuleAction
anchored : Bool
directory_only : Bool
has_separator : Bool
} derive(Eq,
Debug
)

One parsed rule with the original source retained for diagnostics.

#
GlobRules

pub(all) struct GlobRules {
rules : Array[GlobRule]
} derive(Eq,
Debug
)

An ordered rule set using last-match-wins evaluation.

#
GlobRules::allows

fn GlobRules::allows(self : GlobRules, path : String, is_directory : Bool) -> Bool

Returns whether a path should remain visible after rule evaluation.

#
GlobRules::append

fn GlobRules::append(self : GlobRules, other : GlobRules) -> GlobRules

Appends another rule set while preserving evaluation order.

#
GlobRules::decision

fn GlobRules::decision(self : GlobRules, path : String, is_directory : Bool) -> RuleDecision

Evaluates a path with last-match-wins semantics.

#
GlobRules::exclude_count

fn GlobRules::exclude_count(self : GlobRules) -> Int

Returns the count of exclude rules in this set.

#
GlobRules::explain

fn GlobRules::explain(self : GlobRules, path : String, is_directory : Bool) -> String

Describes the last rule that affects a path.

#
GlobRules::filter

fn GlobRules::filter(self : GlobRules, paths : Array[String]) -> Array[String]

Filters a path list, treating every entry as a file.

#
GlobRules::filter_with_kinds

fn GlobRules::filter_with_kinds(self : GlobRules, entries : Array[(String, Bool)]) -> Array[String]

Filters paths when the caller knows which entries are directories.

#
GlobRules::from_lines

fn GlobRules::from_lines(lines : Array[String]) -> Result[GlobRules, GlobError]

Parses lines using common .gitignore-style comments and blank lines.

#
GlobRules::from_text

fn GlobRules::from_text(text : String) -> Result[GlobRules, GlobError]

Parses a newline-separated rule document.

#
GlobRules::include_count

fn GlobRules::include_count(self : GlobRules) -> Int

Returns the count of include rules in this set.

#
GlobRules::is_empty

fn GlobRules::is_empty(self : GlobRules) -> Bool

#
GlobRules::rule_count

fn GlobRules::rule_count(self : GlobRules) -> Int

#
GlobRules::to_array

fn GlobRules::to_array(self : GlobRules) -> Array[GlobRule]

Returns all rules in their source order for tooling integrations.

#
GlobWorkload

pub(all) struct GlobWorkload {
name : String
patterns : Array[String]
paths : Array[String]
} derive(Eq,
Debug
)

A named collection of patterns and deterministic candidate paths.

#
GlobWorkload::name

fn GlobWorkload::name(self : GlobWorkload) -> String

Returns the workload name.

#
GlobWorkload::path_count

fn GlobWorkload::path_count(self : GlobWorkload) -> Int

#
GlobWorkload::paths

fn GlobWorkload::paths(self : GlobWorkload) -> Array[String]

#
GlobWorkload::pattern_count

fn GlobWorkload::pattern_count(self : GlobWorkload) -> Int

#
GlobWorkload::patterns

fn GlobWorkload::patterns(self : GlobWorkload) -> Array[String]

#
GlobWorkload::with_path

fn GlobWorkload::with_path(self : GlobWorkload, path : String) -> GlobWorkload

Adds a path if it is not already present.

#
GlobWorkload::with_pattern

fn GlobWorkload::with_pattern(self : GlobWorkload, pattern : String) -> GlobWorkload

Adds a pattern while preserving input order.

#
IndexStats

pub(all) struct IndexStats {
total : Int
files : Int
directories : Int
hidden : Int
max_depth : Int
} derive(Eq,
Debug
)

Summary statistics for an in-memory path index.

#
MatchReport

pub(all) struct MatchReport {
matched : Array[String]
unmatched : Array[String]
} derive(Eq,
Debug
)

Separates matched and unmatched paths without recompiling the AST.

#
PathIndex

pub(all) struct PathIndex {
entries : Array[PathRecord]
generation : Int
} derive(Eq,
Debug
)

An ordered, duplicate-free collection of normalized path records.

#
PathIndex::add_directory

fn PathIndex::add_directory(self : PathIndex, path : String) -> PathIndex

Inserts or replaces a directory record.

#
PathIndex::add_file

fn PathIndex::add_file(self : PathIndex, path : String) -> PathIndex

Inserts or replaces a file record.

#
PathIndex::add_many

fn PathIndex::add_many(self : PathIndex, entries : Array[PathRecord]) -> PathIndex

Inserts a batch of records in input order.

#
PathIndex::apply_rules

fn PathIndex::apply_rules(self : PathIndex, rules : GlobRules) -> Array[PathRecord]

Applies include/exclude rules to the indexed paths.

#
PathIndex::children

fn PathIndex::children(self : PathIndex, parent : String) -> Array[PathRecord]

Returns direct children of a directory, excluding deeper descendants.

#
PathIndex::clear

fn PathIndex::clear(self : PathIndex) -> PathIndex

Removes all records while advancing the generation.

#
PathIndex::contains

fn PathIndex::contains(self : PathIndex, path : String) -> Bool

#
PathIndex::count_extension

fn PathIndex::count_extension(self : PathIndex, wanted : String) -> Int

Counts records with one extension, without treating directories specially.

#
PathIndex::directories

fn PathIndex::directories(self : PathIndex) -> Array[PathRecord]

#
PathIndex::files

fn PathIndex::files(self : PathIndex) -> Array[PathRecord]

#
PathIndex::from_entries

fn PathIndex::from_entries(entries : Array[PathRecord]) -> PathIndex

Builds an index while removing duplicate normalized paths.

#
PathIndex::generation

fn PathIndex::generation(self : PathIndex) -> Int

Returns the current mutation generation, useful for cache invalidation.

#
PathIndex::get

fn PathIndex::get(self : PathIndex, path : String) -> PathRecord?

Returns the record for a normalized path, if indexed.

#
PathIndex::is_empty

fn PathIndex::is_empty(self : PathIndex) -> Bool

#
PathIndex::length

fn PathIndex::length(self : PathIndex) -> Int

Returns the number of records.

#
PathIndex::new

fn PathIndex::new() -> PathIndex

Starts with an empty index.

#
PathIndex::query

fn PathIndex::query(self : PathIndex, pattern : String) -> Result[Array[PathRecord], GlobError]

Compiles and applies one pattern to the index.

#
PathIndex::query_with_rules

fn PathIndex::query_with_rules(self : PathIndex, pattern : String, rules : GlobRules) -> Result[Array[PathRecord], GlobError]

Returns records matching a pattern and optional rule set.

#
PathIndex::records

fn PathIndex::records(self : PathIndex) -> Array[PathRecord]

Returns records in insertion order.

#
PathIndex::remove

fn PathIndex::remove(self : PathIndex, path : String) -> PathIndex

Removes one path and returns the resulting index.

#
PathIndex::search_compiled

fn PathIndex::search_compiled(self : PathIndex, pattern : CompiledPattern) -> Array[PathRecord]

Matches all indexed records with one compiled pattern.

#
PathIndex::stats

fn PathIndex::stats(self : PathIndex) -> IndexStats

Computes stable aggregate statistics.

#
PathIndex::under

fn PathIndex::under(self : PathIndex, prefix : String) -> Array[PathRecord]

Returns records at or below a normalized directory prefix.

#
PathKind

pub enum PathKind {
File
Directory
} derive(Eq,
Debug
)

The kind of filesystem entry represented by a path record.

#
PathRecord

pub(all) struct PathRecord {
path : String
kind : PathKind
depth : Int
basename : String
extension : String?
hidden : Bool
} derive(Eq,
Debug
)

A normalized path plus metadata used by filtering and reporting tools.

#
PathRecord::directory

fn PathRecord::directory(path : String) -> PathRecord

Creates a directory record.

#
PathRecord::file

fn PathRecord::file(path : String) -> PathRecord

Creates a file record.

#
PathRecord::is_directory

fn PathRecord::is_directory(self : PathRecord) -> Bool

#
PathRecord::is_file

fn PathRecord::is_file(self : PathRecord) -> Bool

#
PathRecord::matches

fn PathRecord::matches(self : PathRecord, pattern : CompiledPattern) -> Bool

Returns true when the record path matches a compiled glob.

#
PathRecord::new

fn PathRecord::new(path : String, kind : PathKind) -> PathRecord

Creates a record with an explicit kind.

#
PatternCache

pub(all) struct PatternCache {
entries : Array[CachedPattern]
capacity : Int
hits : Int
misses : Int
evictions : Int
} derive(Eq,
Debug
)

#
PatternCache::capacity

fn PatternCache::capacity(self : PatternCache) -> Int

#
PatternCache::clear

Clears cached entries and counters while retaining the configured bound.

#
PatternCache::compile_all

fn PatternCache::compile_all(self : PatternCache, sources : Array[String]) -> Result[(PatternCache, Array[CompiledPattern]), GlobError]

Compiles a batch and preserves the first parser error.

#
PatternCache::contains

fn PatternCache::contains(self : PatternCache, source : String) -> Bool

#
PatternCache::entries_count

fn PatternCache::entries_count(self : PatternCache) -> Int

#
PatternCache::filter

fn PatternCache::filter(self : PatternCache, source : String, paths : Array[String]) -> Result[(PatternCache, Array[String]), GlobError]

Filters paths with a cached pattern.

#
PatternCache::get_or_compile

fn PatternCache::get_or_compile(self : PatternCache, source : String) -> Result[(PatternCache, CompiledPattern), GlobError]

Returns a compiled pattern and an updated cache.

#
PatternCache::hit_rate_percent

fn PatternCache::hit_rate_percent(self : PatternCache) -> Int

#
PatternCache::match_all

fn PatternCache::match_all(self : PatternCache, sources : Array[String], path : String) -> Result[(PatternCache, Bool), GlobError]

Tests whether every pattern matches one path.

#
PatternCache::match_any

fn PatternCache::match_any(self : PatternCache, sources : Array[String], paths : Array[String]) -> Result[(PatternCache, Bool), GlobError]

Tests whether at least one cached/compiled pattern matches any path.

#
PatternCache::new

fn PatternCache::new(capacity : Int) -> Result[PatternCache, CacheError]

#
PatternCache::sources

fn PatternCache::sources(self : PatternCache) -> Array[String]

Returns all cached source names in oldest-to-newest order.

#
PatternCache::stats

fn PatternCache::stats(self : PatternCache) -> CacheStats

#
PatternCache::summary

fn PatternCache::summary(self : PatternCache) -> String

#
PatternExplanation

pub(all) struct PatternExplanation {
source : String
normalized : String
tokens : Array[String]
ast_text : String
stats : PatternStats
risk : PatternRisk
literal_prefix : String
separator_count : Int
} derive(Eq,
Debug
)

A complete, stable explanation of one validated pattern.

#
PatternExplanation::branch_count

fn PatternExplanation::branch_count(self : PatternExplanation) -> Int

#
PatternExplanation::complexity_score

fn PatternExplanation::complexity_score(self : PatternExplanation) -> Int

#
PatternExplanation::has_recursive_wildcard

fn PatternExplanation::has_recursive_wildcard(self : PatternExplanation) -> Bool

#
PatternExplanation::is_literal

fn PatternExplanation::is_literal(self : PatternExplanation) -> Bool

#
PatternExplanation::recommendation

fn PatternExplanation::recommendation(self : PatternExplanation) -> String

Recommends a caller-visible execution strategy.

#
PatternExplanation::risk_name

fn PatternExplanation::risk_name(self : PatternExplanation) -> String

Returns a compact machine-readable category name.

#
PatternExplanation::signature

fn PatternExplanation::signature(self : PatternExplanation) -> String

Produces a stable identifier suitable for benchmark grouping.

#
PatternExplanation::summary

fn PatternExplanation::summary(self : PatternExplanation) -> String

Renders a short one-line diagnostic for logs and CLI output.

#
PatternExplanation::token_count

fn PatternExplanation::token_count(self : PatternExplanation) -> Int

#
PatternRisk

pub enum PatternRisk {
Literal
Bounded
Recursive
HighBranching
} derive(Eq,
Debug
)

A coarse risk category used to choose traversal and caching strategies.

#
PatternStats

pub(all) struct PatternStats {
literal_chars : Int
star_count : Int
globstar_count : Int
question_count : Int
char_class_count : Int
brace_group_count : Int
escaped_char_count : Int
} derive(Eq,
Debug
)

Counts the syntax features in a compiled glob pattern.

#
PatternStats::has_magic

fn PatternStats::has_magic(self : PatternStats) -> Bool

Returns true when the pattern has at least one wildcard construct.

#
PatternStats::is_literal

fn PatternStats::is_literal(self : PatternStats) -> Bool

Returns true when the pattern contains no wildcard constructs.

#
PatternStats::magic_count

fn PatternStats::magic_count(self : PatternStats) -> Int

Returns the number of syntax constructs that require matching logic.

#
PipelineError

pub enum PipelineError {
InvalidLimit
} derive(Eq,
Debug
)

#
PipelineReport

pub(all) struct PipelineReport {
scanned : Int
included : Int
excluded : Int
returned : Int
truncated : Bool
results : Array[String]
cache_hits : Int
cache_misses : Int
} derive(Eq,
Debug
)

#
PipelineReport::csv_header

fn PipelineReport::csv_header(_self : PipelineReport) -> String

#
PipelineReport::csv_row

fn PipelineReport::csv_row(self : PipelineReport) -> String

#
PipelineReport::has_results

fn PipelineReport::has_results(self : PipelineReport) -> Bool

#
PipelineReport::summary

fn PipelineReport::summary(self : PipelineReport) -> String

#
QueryReport

pub(all) struct QueryReport {
examined : Int
included : Int
excluded : Int
returned : Int
truncated : Bool
results : Array[String]
} derive(Eq,
Debug
)

A report returned by a path query.

#
QueryReport::has_results

fn QueryReport::has_results(self : QueryReport) -> Bool

Returns whether the query produced at least one result.

#
QueryReport::is_complete

fn QueryReport::is_complete(self : QueryReport) -> Bool

Returns whether the result set contains every accepted path.

#
QueryReport::page

fn QueryReport::page(self : QueryReport, offset : Int, page_size : Int) -> Array[String]

Returns a bounded page of results without changing the original report. Invalid offsets and page sizes produce an empty page.

#
QueryReport::returned_count

fn QueryReport::returned_count(self : QueryReport) -> Int

Returns the number of results in the current pageable report.

#
QueryReport::summary

fn QueryReport::summary(self : QueryReport) -> String

Returns a compact summary suitable for build logs and diagnostics.

#
RuleAction

pub enum RuleAction {
Include
Exclude
} derive(Eq,
Debug
)

The action encoded by one ignore-file rule.

#
RuleDecision

pub enum RuleDecision {
Included
Excluded
Unmatched
} derive(Eq,
Debug
)

The result of evaluating all rules for one path.

#
Token

pub enum Token {
Text(String)
Question
Star
GlobStar
LBrace
RBrace
Comma
LBracket
RBracket
Negate
Char(Char)
Range(Char, Char)
} derive(Eq,
Debug
)

Represents a token produced by the Glob lexer.

#
TraversalPlan

pub(all) struct TraversalPlan {
pattern : CompiledPattern
root_prefix : String
recursive : Bool
literal : Bool
} derive(Eq,
Debug
)

#
TraversalPlan::can_descend

fn TraversalPlan::can_descend(self : TraversalPlan, relative_path : String) -> Bool

Returns whether a relative directory can contain a matching path.

#
TraversalPlan::describe

fn TraversalPlan::describe(self : TraversalPlan) -> String

#
TraversalPlan::estimated_skipped_levels

fn TraversalPlan::estimated_skipped_levels(self : TraversalPlan, current_depth : Int) -> Int

Returns a simple estimate of how many directory levels can be skipped.

#
TraversalPlan::from_compiled

fn TraversalPlan::from_compiled(pattern : CompiledPattern) -> TraversalPlan

#
TraversalPlan::from_pattern

fn TraversalPlan::from_pattern(pattern : String) -> Result[TraversalPlan, GlobError]

Builds a plan and compiles the pattern exactly once.

#
TraversalPlan::is_literal

fn TraversalPlan::is_literal(self : TraversalPlan) -> Bool

#
TraversalPlan::is_prunable

fn TraversalPlan::is_prunable(self : TraversalPlan) -> Bool

#
TraversalPlan::is_recursive

fn TraversalPlan::is_recursive(self : TraversalPlan) -> Bool

#
TraversalPlan::matches

fn TraversalPlan::matches(self : TraversalPlan, path : String) -> Bool

#
TraversalPlan::pattern

#
TraversalPlan::prefix_depth

fn TraversalPlan::prefix_depth(self : TraversalPlan) -> Int

Returns the number of static path components used for pruning.

#
TraversalPlan::start_prefix

fn TraversalPlan::start_prefix(self : TraversalPlan, dir : String) -> String

Chooses a safe starting prefix when it exists on the filesystem.

#
WorkloadError

pub enum WorkloadError {
InvalidSize
TooLarge
} derive(Eq,
Debug
)

#
WorkloadResult

pub(all) struct WorkloadResult {
workload_name : String
pattern_count : Int
path_count : Int
matches : Int
patterns_with_matches : Int
invalid_patterns : Int
literal_patterns : Int
recursive_patterns : Int
} derive(Eq,
Debug
)

Aggregate results from evaluating every pattern against every candidate.

#
WorkloadResult::coverage_percent

fn WorkloadResult::coverage_percent(self : WorkloadResult) -> Int

#
WorkloadResult::csv_header

fn WorkloadResult::csv_header(_self : WorkloadResult) -> String

#
WorkloadResult::csv_row

fn WorkloadResult::csv_row(self : WorkloadResult) -> String

#
WorkloadResult::has_invalid_patterns

fn WorkloadResult::has_invalid_patterns(self : WorkloadResult) -> Bool

#
WorkloadResult::is_useful

fn WorkloadResult::is_useful(self : WorkloadResult) -> Bool

#
WorkloadResult::summary

fn WorkloadResult::summary(self : WorkloadResult) -> String

#
analyze

fn analyze(pattern : String) -> Result[PatternStats, GlobError]

Compiles and analyzes a pattern without performing any path matching.

#
basename

fn basename(path : String) -> String

Returns the final component of a path.

#
build_default_workload

fn build_default_workload() -> GlobWorkload

A compact workload suitable for every CI run.

#
build_large_workload

fn build_large_workload() -> GlobWorkload

A larger workload for local performance checks and release notes.

#
build_query

fn build_query(includes : Array[String], excludes : Array[String]) -> Result[GlobQuery, GlobError]

Creates a query from include and exclude source patterns.

#
build_workload

fn build_workload(depth : Int, width : Int) -> Result[GlobWorkload, WorkloadError]

Builds a reproducible repository-shaped workload.

#
classify_paths

fn classify_paths(ast : AST, paths : Array[String]) -> MatchReport

Classifies a path list with one compiled pattern.

#
compile

fn compile(pattern : String) -> Result[AST, GlobError]

Compiles a glob pattern string into an AST.

#
compile_many

fn compile_many(patterns : Array[String]) -> Result[Array[AST], GlobError]

Compiles patterns in input order and stops at the first invalid pattern.

#
compile_pattern

fn compile_pattern(pattern : String) -> Result[CompiledPattern, GlobError]

Compiles one pattern and records metadata without changing matching rules.

#
compile_patterns

fn compile_patterns(patterns : Array[String]) -> Result[Array[CompiledPattern], GlobError]

Compiles a batch while preserving the caller's pattern order.

#
dirname

fn dirname(path : String) -> String

Returns the parent path, or . when the path has no parent.

#
evaluate_workload

fn evaluate_workload(workload : GlobWorkload) -> WorkloadResult

Evaluates a workload with one compilation per pattern and no timing noise.

#
explain_pattern

fn explain_pattern(pattern : String) -> Result[PatternExplanation, GlobError]

Parses a pattern and returns all information needed for diagnostics.

#
extension

fn extension(path : String) -> String?

Returns the final extension without the leading dot.

#
filter

fn filter(pattern : String, paths : Array[String]) -> Result[Array[String], GlobError]

Filters an array of paths, returning only those that match the glob pattern.

#
filter_compiled

fn filter_compiled(ast : AST, paths : Array[String]) -> Array[String]

Filters paths with a previously compiled pattern.

#
filter_compiled_patterns

fn filter_compiled_patterns(patterns : Array[CompiledPattern], paths : Array[String]) -> Array[String]

Filters a path list using compiled patterns and removes duplicate results.

#
filter_not

fn filter_not(pattern : String, paths : Array[String]) -> Result[Array[String], GlobError]

Filters an array of paths, returning only those that do NOT match the glob pattern.

#
filter_not_compiled

fn filter_not_compiled(ast : AST, paths : Array[String]) -> Array[String]

Filters out paths with a previously compiled pattern.

#
filter_not_compiled_patterns

fn filter_not_compiled_patterns(patterns : Array[CompiledPattern], paths : Array[String]) -> Array[String]

Returns the paths that match none of the compiled patterns.

#
glob

fn glob(dir : String, pattern : String) -> Result[Array[String], GlobError]

Searches the filesystem starting from dir for paths matching the glob pattern. The returned paths are relative to dir.

#
glob_with_options

fn glob_with_options(dir : String, pattern : String, options : GlobOptions) -> Result[Array[String], GlobError]

Searches the filesystem using explicit filtering and traversal options.

#
has_recursive_wildcard

fn has_recursive_wildcard(pattern : String) -> Result[Bool, GlobError]

Returns whether a pattern contains a recursive ** wildcard.

#
is_hidden_path

fn is_hidden_path(path : String) -> Bool

Returns true when any path component starts with a dot.

#
is_path_pattern

fn is_path_pattern(pattern : String) -> Result[Bool, GlobError]

Returns whether a valid pattern contains a path separator.

#
literal_prefix

fn literal_prefix(pattern : String) -> Result[String, GlobError]

Returns the static prefix before the first wildcard construct.

#
match_all

fn match_all(patterns : Array[String], path : String) -> Result[Bool, GlobError]

Returns true only when every pattern matches the path.

#
match_any

fn match_any(patterns : Array[String], path : String) -> Result[Bool, GlobError]

Returns true when at least one pattern matches the path.

#
match_compiled_all

fn match_compiled_all(patterns : Array[CompiledPattern], path : String) -> Bool

Matches one path against every previously compiled pattern.

#
match_compiled_any

fn match_compiled_any(patterns : Array[CompiledPattern], path : String) -> Bool

Matches one path against any previously compiled pattern.

#
match_path

fn match_path(ast : AST, path : String) -> Bool

Matches a path string against a parsed Glob AST.

#
match_pattern

fn match_pattern(pattern : String, path : String) -> Result[Bool, GlobError]

Matches a path string against a glob pattern string.

#
normalize_path

fn normalize_path(path : String) -> String

Converts Windows separators to /, removes duplicate separators, and removes a leading ./ from a relative path.

#
parse

fn parse(tokens : Array[Token]) -> Result[AST, GlobError]

Converts a flat array of Tokens into a hierarchical AST.

#
path_depth

fn path_depth(path : String) -> Int

Returns the number of non-empty path components.

#
query_paths

fn query_paths(includes : Array[String], excludes : Array[String], paths : Array[String]) -> Result[QueryReport, GlobError]

Executes a one-shot include/exclude query over a path list.

#
separator_count

fn separator_count(pattern : String) -> Result[Int, GlobError]

Returns the number of / separators in a valid pattern.

#
static_segments

fn static_segments(pattern : String) -> Result[Array[String], GlobError]

Returns the literal path components known before the first wildcard.

#
tokenize

fn tokenize(pattern : String) -> Result[Array[Token], GlobError]

Tokenizes a glob pattern string into a sequence of Tokens.