pub struct Expr {
root: Node,
}Expand description
A compiled condition expression in APISIX’s triple-array form.
Parsed once at config load (Expr::parse); regexes are compiled at
parse time so evaluation is allocation-light.
Fields§
§root: NodeImplementations§
Source§impl Expr
impl Expr
Sourcepub fn parse(v: &Value) -> Result<Self, String>
pub fn parse(v: &Value) -> Result<Self, String>
Parses the APISIX vars shape: a JSON array of rules, ANDed.
Each rule is [var, op, value], [var, "!", op, value], or a nested
["AND"|"OR", rule...]. Fails with a descriptive message on unknown
operators, malformed rules, invalid regexes, or invalid CIDRs.
Sourcepub fn references_response_body(&self) -> bool
pub fn references_response_body(&self) -> bool
Evaluates the expression against the context. Rules referencing absent
variables evaluate as if the variable were the empty string, except
ipmatch, which is false for an absent/unparsable address. JSONPath
subjects match zero nodes (rule is false) when the body is empty or
not valid JSON.
Whether evaluating this expression reads context.response.body.
Consulted at policy-compile time by the nodes that gate on a condition
(traffic-label’s matchers, response-rewrite’s vars): a condition
on the response body makes the node a body reader even though none of
its other config touches the body, so the node must not report itself
stream-safe.
pub fn eval(&self, ctx: &Context) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Expr
impl !UnwindSafe for Expr
impl Freeze for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more