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 partial_eval_unknown(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
arg_type: SchemaType,
) -> Self
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.
Sourcepub fn unary(
name: Name,
style: CallStyle,
func: Box<dyn Fn(Value) -> Result<ExtensionOutputValue, EvaluationError> + Sync + Send + 'static>,
return_type: SchemaType,
arg_type: 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: 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: (SchemaType, 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: (SchemaType, 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: (SchemaType, SchemaType, 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: (SchemaType, SchemaType, 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
is returned exactly when this function represents an “unknown”
for partial evaluation.
Sourcepub fn arg_types(&self) -> &[SchemaType]
pub fn arg_types(&self) -> &[SchemaType]
Get the argument types of the ExtensionFunction
.
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