cedar_policy_core::ast

Struct ExtensionFunction

Source
pub struct ExtensionFunction { /* private fields */ }
Expand description

Extension function. These can be called by the given name in Ceder expressions.

Implementations§

Source§

impl ExtensionFunction

Source

pub fn nullary( name: Name, style: CallStyle, func: Box<dyn Fn() -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, ) -> Self

Create a new ExtensionFunction taking no arguments

Source

pub fn partial_eval_unknown( name: Name, style: CallStyle, func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, arg_type: SchemaType, ) -> Self

Create a new ExtensionFunction to represent a function which is an “unknown” in partial evaluation. Please don’t use this for anything else.

Source

pub fn unary( name: Name, style: CallStyle, func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, arg_type: SchemaType, ) -> Self

Create a new ExtensionFunction taking one argument

Source

pub fn binary( name: Name, style: CallStyle, func: Box<dyn Fn(Value, Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, arg_types: (SchemaType, SchemaType), ) -> Self

Create a new ExtensionFunction taking two arguments

Source

pub fn ternary( name: Name, style: CallStyle, func: Box<dyn Fn(Value, Value, Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, arg_types: (SchemaType, SchemaType, SchemaType), ) -> Self

Create a new ExtensionFunction taking three arguments

Source

pub fn name(&self) -> &Name

Get the Name of the ExtensionFunction

Source

pub fn style(&self) -> CallStyle

Get the CallStyle of the ExtensionFunction

Source

pub fn return_type(&self) -> Option<&SchemaType>

Get the return type of the ExtensionFunction None is returned exactly when this function represents an “unknown” for partial evaluation.

Source

pub fn arg_types(&self) -> &[SchemaType]

Get the argument types of the ExtensionFunction.

Source

pub fn is_constructor(&self) -> bool

Returns true if this function is considered a “constructor”.

Currently, the only impact of this is that non-constructors are not accessible in the JSON format (entities/json.rs).

Source

pub fn call(&self, args: &[Value]) -> Result<PartialValue, EvaluationError>

Call the ExtensionFunction with the given args

Source

pub fn ext_types(&self) -> impl Iterator<Item = &Name> + '_

Iterate over the extension types that could be produced by this function, if any

Trait Implementations§

Source§

impl Debug for ExtensionFunction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.