Struct scratchstack_aspen::Context
source · [−]pub struct Context { /* private fields */ }Expand description
The request context used when evaluating an Aspen policy.
Context structures are immutable.
Implementations
sourceimpl Context
impl Context
sourcepub fn builder() -> ContextBuilder
pub fn builder() -> ContextBuilder
Returns a new ContextBuilder for building a Context.
sourcepub fn resources(&self) -> &Vec<Arn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn resources(&self) -> &Vec<Arn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Returns the resources associated with the request.
sourcepub fn session_data(&self) -> &SessionData
pub fn session_data(&self) -> &SessionData
Returrns the session data associated with the request.
sourcepub fn matcher<T: AsRef<str>>(
&self,
s: T,
pv: PolicyVersion,
case_insensitive: bool
) -> Result<Regex, AspenError>
pub fn matcher<T: AsRef<str>>(
&self,
s: T,
pv: PolicyVersion,
case_insensitive: bool
) -> Result<Regex, AspenError>
Creates a Regex from the given string pattern and policy version.
If case_insensitive is true, the returned Regex will be case insensitive.
Wildcards are converted to their regular expression equivalents. If the policy version is
PolicyVersion::V2012_10_17 or later, variables are substituted and regex-escaped as necessary. The special
variables ${*}, ${$}, and ${?} are converted to literal *, $, and ? characters, respectively, then
regex-escaped.
Errors
If the string contains a malformed variable reference and PolicyVersion::V2012_10_17 or later is used, AspenError::InvalidSubstitution is returned.
sourcepub fn subst_vars_plain(&self, s: &str) -> Result<String, AspenError>
pub fn subst_vars_plain(&self, s: &str) -> Result<String, AspenError>
Substitutes variables from the given string, returning the resulting string.
Errors
If the string contains a malformed variable reference and PolicyVersion::V2012_10_17 or later is used, AspenError::InvalidSubstitution is returned.