1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::core::Request;
pub trait ResourceMatcher {
type Context;
fn do_match(&self, context: &Request<Self::Context>, input: &str, policy: &str) -> bool;
}
#[derive(Debug)]
pub struct Default;
impl ResourceMatcher for Default {
type Context = ();
fn do_match(&self, _context: &Request<Self::Context>, input: &str, policy: &str) -> bool {
input == policy
}
}
#[derive(Debug)]
pub struct StartsWith;
impl ResourceMatcher for StartsWith {
type Context = ();
fn do_match(&self, _context: &Request<Self::Context>, input: &str, policy: &str) -> bool {
input.starts_with(policy)
}
}