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