MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / matches_pattern

Function matches_pattern

nodedb/src/engine/kv/scan.rs:107–112  ·  view source on GitHub ↗

Simple glob-style pattern matching for SCAN MATCH. Supports `*` (match any sequence) and `?` (match single byte). `None` pattern matches everything.

(key: &[u8], pattern: Option<&str>)

Source from the content-addressed store, hash-verified

105/// Supports `*` (match any sequence) and `?` (match single byte).
106/// `None` pattern matches everything.
107fn matches_pattern(key: &[u8], pattern: Option<&str>) -> bool {
108 let Some(pattern) = pattern else {
109 return true;
110 };
111 glob_match(pattern.as_bytes(), key)
112}
113
114/// Glob matching: `*` matches zero or more bytes, `?` matches exactly one byte.
115pub(crate) fn glob_match(pattern: &[u8], input: &[u8]) -> bool {

Callers 2

scan_with_surrogateMethod · 0.85
matches_pattern_pubFunction · 0.85

Calls 2

glob_matchFunction · 0.85
as_bytesMethod · 0.45

Tested by

no test coverage detected