Skip to main content

CelConstraint

Struct CelConstraint 

Source
pub struct CelConstraint {
    pub id: &'static str,
    pub message: &'static str,
    pub expression: &'static str,
    /* private fields */
}

Fields§

§id: &'static str§message: &'static str§expression: &'static str

Implementations§

Source§

impl CelConstraint

Source

pub const fn new( id: &'static str, message: &'static str, expression: &'static str, ) -> Self

Source

pub fn eval_value_at( &self, this: Value, field_path: FieldPath, cel_index: u64, ) -> Result<(), Violation>

Evaluates this CEL expression against this (bound as the this variable inside the expression) plus a per-call-frozen now timestamp.

§Errors

Returns a Violation when the compiled CEL expression returns false, returns a non-empty string, or produces a runtime error.

§Panics

Panics at first call if the CEL expression fails to compile (it is baked in at codegen time, so a parse failure indicates a plugin bug). Evaluate this CEL expression with this bound to the supplied raw crate::cel_core::Value (used for scalar-field-level CEL rules where the “this” target is a primitive, not a message). The violation’s field path is set from field_path and rule path is set to [cel[index]] reflecting position in the repeated FieldRules.cel.

Source

pub fn eval_expr_value_at( &self, this: Value, field_path: FieldPath, index: u64, ) -> Result<(), Violation>

Like eval_value_at but for (field).cel_expression (string) constraints — the rule path uses field_number=29, field_name="cel_expression", field_type=String instead of cel’s field_number=23/field_type=Message.

§Errors

Returns a Violation when the CEL expression rejects this.

Source

pub fn eval_repeated_items_cel( &self, this: Value, field_path: FieldPath, cel_idx: u64, ) -> Result<(), Violation>

Evaluate for a repeated.items.cel[idx] rule. Rule path is [repeated(18), items(4), cel(23, index:cel_idx)].

§Errors

Returns a Violation when the CEL expression rejects this.

Source

pub fn eval_map_keys_cel( &self, this: Value, field_path: FieldPath, cel_idx: u64, ) -> Result<(), Violation>

map.keys.cel[idx]for_key=true.

§Errors

Returns a Violation when the CEL expression rejects this.

Source

pub fn eval_map_values_cel( &self, this: Value, field_path: FieldPath, cel_idx: u64, ) -> Result<(), Violation>

map.values.cel[idx].

§Errors

Returns a Violation when the CEL expression rejects this.

Source

pub fn eval_predefined( &self, this: Value, rule: Value, field_path: FieldPath, rule_path: FieldPath, ) -> Result<(), Violation>

Evaluate a predefined-rule CEL expression with this and rule bindings. Caller supplies the complete field_path and rule_path.

§Errors

Returns a Violation when the CEL expression rejects this.

§Panics

Panics if the CEL expression fails to compile (baked in at codegen time).

Source

pub fn eval_value(&self, this: Value) -> Result<(), Violation>

Evaluate with this already bound as a raw CEL Value.

§Errors

Returns a Violation when the CEL expression rejects this.

§Panics

Panics if the CEL expression fails to compile (baked in at codegen time).

Source

pub fn eval<T: AsCelValue>(&self, this: &T) -> Result<(), Violation>

Evaluate with this bound via the AsCelValue trait.

§Errors

Returns a Violation when the CEL expression rejects this or when a non-skippable runtime error occurs.

§Panics

Panics if the CEL expression fails to compile (baked in at codegen time).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

fn coerce_mut_to(&mut self) -> &mut T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more