Struct cedar_policy_core::ast::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
impl ExtensionFunction
sourcepub fn nullary(
name: Name,
style: CallStyle,
func: Box<dyn Fn() -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
return_type: SchemaType,
) -> Self
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
sourcepub fn unary_never(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
arg_type: Option<SchemaType>,
) -> Self
pub fn unary_never( name: Name, style: CallStyle, func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, arg_type: Option<SchemaType>, ) -> Self
Create a new ExtensionFunction
taking one argument, that never returns a value
sourcepub fn unary(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
return_type: SchemaType,
arg_type: Option<SchemaType>,
) -> Self
pub fn unary( name: Name, style: CallStyle, func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, arg_type: Option<SchemaType>, ) -> Self
Create a new ExtensionFunction
taking one argument
sourcepub fn binary(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value, Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
return_type: SchemaType,
arg_types: (Option<SchemaType>, Option<SchemaType>),
) -> Self
pub fn binary( name: Name, style: CallStyle, func: Box<dyn Fn(Value, Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>, return_type: SchemaType, arg_types: (Option<SchemaType>, Option<SchemaType>), ) -> Self
Create a new ExtensionFunction
taking two arguments
sourcepub fn ternary(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value, Value, Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
return_type: SchemaType,
arg_types: (Option<SchemaType>, Option<SchemaType>, Option<SchemaType>),
) -> Self
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: (Option<SchemaType>, Option<SchemaType>, Option<SchemaType>), ) -> Self
Create a new ExtensionFunction
taking three arguments
sourcepub fn return_type(&self) -> Option<&SchemaType>
pub fn return_type(&self) -> Option<&SchemaType>
Get the return type of the ExtensionFunction
None
represents the Never
type.
sourcepub fn arg_types(&self) -> &[Option<SchemaType>]
pub fn arg_types(&self) -> &[Option<SchemaType>]
Get the argument types of the ExtensionFunction
.
If any given argument type is not constant (function works with multiple
SchemaType
s) then this will be None
for that argument.
sourcepub fn is_constructor(&self) -> bool
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).
sourcepub fn call(&self, args: &[Value]) -> Result<PartialValue, EvaluationError>
pub fn call(&self, args: &[Value]) -> Result<PartialValue, EvaluationError>
Call the ExtensionFunction
with the given args
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExtensionFunction
impl !RefUnwindSafe for ExtensionFunction
impl Send for ExtensionFunction
impl Sync for ExtensionFunction
impl Unpin for ExtensionFunction
impl !UnwindSafe for ExtensionFunction
Blanket Implementations§
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
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