vynil-core 0.7.5

A Rust toolbox for bootstrapping projects combining a Rhai scripting engine and a Handlebars templating engine, with optional Kubernetes / OCI / S3 handlers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Glob matching helper for Rhai (`glob` function wrapping `wildmatch`).

use rhai::{Engine, ImmutableString};
use wildmatch::WildMatch;

fn glob_fn(text: ImmutableString, pattern: ImmutableString) -> bool {
    WildMatch::new(pattern.as_ref()).matches(text.as_ref())
}

/// Register the `glob(text, pattern) -> bool` Rhai helper.
pub fn glob_rhai_register(engine: &mut Engine) {
    engine.register_fn("glob", glob_fn);
}