Trait cedar_policy_core::ast::InternalExtensionValue

source ·
pub trait InternalExtensionValue: ExtensionValue {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn equals_extvalue(&self, other: &dyn InternalExtensionValue) -> bool;
    fn cmp_extvalue(&self, other: &dyn InternalExtensionValue) -> Ordering;
}
Expand description

Extensions provide a type implementing ExtensionValue, Eq, and Ord. We automatically implement InternalExtensionValue for that type (with the impl below). Internally, we use dyn InternalExtensionValue instead of dyn ExtensionValue.

You might wonder why we don’t just have ExtensionValue: Eq + Ord and use dyn ExtensionValue everywhere. The answer is that the Rust compiler doesn’t let you because of object safety. So instead we have this workaround where we define our own equals_extvalue method that compares not against &Self but against &dyn InternalExtensionValue, and likewise for cmp_extvalue.

Required Methods§

source

fn as_any(&self) -> &dyn Any

convert to an Any

source

fn equals_extvalue(&self, other: &dyn InternalExtensionValue) -> bool

this will be the basis for PartialEq on InternalExtensionValue; but note the &dyn (normal PartialEq doesn’t have the dyn)

source

fn cmp_extvalue(&self, other: &dyn InternalExtensionValue) -> Ordering

this will be the basis for Ord on InternalExtensionValue; but note the &dyn (normal Ord doesn’t have the dyn)

Trait Implementations§

source§

impl Ord for dyn InternalExtensionValue

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl PartialEq for dyn InternalExtensionValue

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for dyn InternalExtensionValue

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StaticallyTyped for dyn InternalExtensionValue

source§

fn type_of(&self) -> Type

Get the object’s type
source§

impl Eq for dyn InternalExtensionValue

Implementors§