Skip to main content

MessageValue

Trait MessageValue 

Source
pub trait MessageValue:
    Debug
    + Send
    + Sync {
    // Required methods
    fn type_name(&self) -> &str;
    fn eq_message(&self, other: &dyn MessageValue) -> bool;
    fn as_any(&self) -> &dyn Any;
    fn clone_boxed(&self) -> Box<dyn MessageValue>;

    // Provided method
    fn is_default(&self) -> Option<bool> { ... }
}
Expand description

A trait representing a protobuf message value at runtime.

This abstraction allows cel-core to work with proto messages without depending on a specific protobuf library (e.g., prost-reflect).

§Object Safety

This trait is object-safe and can be used with dyn MessageValue.

§Downcasting

The as_any() method enables downcasting to concrete types. Note that downcasting only works with the exact concrete type - wrapped or newtype implementations will not match. Equality comparisons via eq_message() will return false for different concrete types even if they represent the same message content.

§Map Keys

MessageValue does not support hashing, so proto messages cannot be used as map keys in CEL. This matches the CEL specification.

Required Methods§

Source

fn type_name(&self) -> &str

Get the fully qualified type name of this message.

Source

fn eq_message(&self, other: &dyn MessageValue) -> bool

Check equality with another message value.

Source

fn as_any(&self) -> &dyn Any

Downcast to a concrete type via Any.

Source

fn clone_boxed(&self) -> Box<dyn MessageValue>

Clone this message value into a boxed trait object.

Provided Methods§

Source

fn is_default(&self) -> Option<bool>

Returns true if this message is a “zero value” (all fields are default/unset).

Used by optionals extension for hasValue() / or() semantics. Returns None if the implementation cannot determine default status.

Trait Implementations§

Source§

impl Clone for Box<dyn MessageValue>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§