MCPcopy Create free account
hub / github.com/FeatureProbe/server-sdk-rust / match_string

Method match_string

src/evaluate.rs:468–494  ·  view source on GitHub ↗
(&self, user: &FPUser, predicate: &str)

Source from the content-addressed store, hash-verified

466 }
467
468 fn match_string(&self, user: &FPUser, predicate: &str) -> bool {
469 if let Some(c) = user.get(&self.subject) {
470 return match predicate {
471 "is one of" => self.do_match::<String>(c, |c, o| c.eq(o)),
472 "ends with" => self.do_match::<String>(c, |c, o| c.ends_with(o)),
473 "starts with" => self.do_match::<String>(c, |c, o| c.starts_with(o)),
474 "contains" => self.do_match::<String>(c, |c, o| c.contains(o)),
475 "matches regex" => {
476 self.do_match::<String>(c, |c, o| match Regex::new(o) {
477 Ok(re) => re.is_match(c),
478 Err(_) => false, // invalid regex should be checked when load config
479 })
480 }
481 "is not any of" => !self.match_string(user, "is one of"),
482 "does not end with" => !self.match_string(user, "ends with"),
483 "does not start with" => !self.match_string(user, "starts with"),
484 "does not contain" => !self.match_string(user, "contains"),
485 "does not match regex" => !self.match_string(user, "matches regex"),
486 _ => {
487 info!("unknown predicate {}", predicate);
488 false
489 }
490 };
491 }
492 info!("user attr missing: {}", self.subject);
493 false
494 }
495
496 fn match_ordering<T: FromStr + PartialOrd>(&self, user: &FPUser, predicate: &str) -> bool {
497 if let Some(c) = user.get(&self.subject) {

Callers 1

meetMethod · 0.80

Calls 2

getMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected