pub struct FilterResultSet { /* private fields */ }Expand description
Result feedback from a single filter execution.
Filters populate this to communicate outcomes (e.g. cache hit/miss, auth success/failure) without knowing about branching.
use praxis_filter::FilterResultSet;
let mut results = FilterResultSet::new();
results.set("status", "hit").unwrap();
assert_eq!(results.get("status"), Some("hit"));
assert!(results.matches("status", "hit"));
assert!(!results.matches("status", "miss"));Implementations§
Source§impl FilterResultSet
impl FilterResultSet
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty result set.
use praxis_filter::FilterResultSet;
let rs = FilterResultSet::new();
assert!(rs.is_empty());Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Get a result value by key.
use praxis_filter::FilterResultSet;
let mut rs = FilterResultSet::new();
rs.set("action", "allow").unwrap();
assert_eq!(rs.get("action"), Some("allow"));
assert_eq!(rs.get("missing"), None);Sourcepub fn matches(&self, key: &str, value: &str) -> bool
pub fn matches(&self, key: &str, value: &str) -> bool
Whether a key-value pair matches.
use praxis_filter::FilterResultSet;
let mut rs = FilterResultSet::new();
rs.set("tier", "premium").unwrap();
assert!(rs.matches("tier", "premium"));
assert!(!rs.matches("tier", "free"));
assert!(!rs.matches("missing", "x"));Sourcepub fn set(
&mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Result<(), FilterError>
pub fn set( &mut self, key: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>, ) -> Result<(), FilterError>
Set a result key-value pair.
§Errors
Returns FilterError if:
keyis empty, exceeds 64 bytes, or contains non-ASCII-alphanumeric characters (besides_and-)valueexceeds 256 bytes or contains control characters (0x00-0x1F except 0x09/tab)
use praxis_filter::FilterResultSet;
let mut rs = FilterResultSet::new();
assert!(rs.set("valid-key_1", "value").is_ok());
assert!(rs.set("", "value").is_err());Trait Implementations§
Source§impl Clone for FilterResultSet
impl Clone for FilterResultSet
Source§fn clone(&self) -> FilterResultSet
fn clone(&self) -> FilterResultSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FilterResultSet
impl Debug for FilterResultSet
Source§impl Default for FilterResultSet
impl Default for FilterResultSet
Source§fn default() -> FilterResultSet
fn default() -> FilterResultSet
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FilterResultSet
impl RefUnwindSafe for FilterResultSet
impl Send for FilterResultSet
impl Sync for FilterResultSet
impl Unpin for FilterResultSet
impl UnsafeUnpin for FilterResultSet
impl UnwindSafe for FilterResultSet
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more