[−][src]Trait ketos::value::ForeignValue
Represents a type of value defined outside the core interpreter.
Required methods
Loading content...Provided methods
fn compare_to(&self, rhs: &dyn ForeignValue) -> Result<Ordering, ExecError>
Performs ordered comparison between two values of a foreign type.
If a true, Ord
-like comparison cannot be made,
ExecError::CannotCompare(..)
should be returned.
The default implementation unconditionally returns an error.
fn compare_to_value(&self, rhs: &Value) -> Result<Ordering, ExecError>
Performs ordered comparison between two values.
This method need only be implemented if a value of the foreign type may be compared with core value types.
fn is_identical_to(&self, rhs: &dyn ForeignValue) -> bool
Returns whether the two values are identical.
This concept is the same as equality, except in the case of floating
point values, where two NaN
values are considered identical.
A type implementing ForeignValue
need only implement is_identical
if it contains a float-type value or emulates some equality relationship
similar to NaN
.
fn is_equal_to(&self, rhs: &dyn ForeignValue) -> Result<bool, ExecError>
Tests for equality between two values of a foreign type.
The default implementation unconditionally returns an error.
fn is_equal_to_value(&self, rhs: &Value) -> Result<bool, ExecError>
Tests for equality between two values.
This method need only be implemented if a value of the foreign type may be compared with core value types.
fn fmt_debug(&self, names: &NameStore, f: &mut Formatter) -> Result
Format the value in debugging mode.
The default implementation uses the type's fmt::Debug
representation.
fn fmt_display(&self, names: &NameStore, f: &mut Formatter) -> Result
Format the value in display mode.
The default implementation formats the value in debugging mode.
fn is_type(&self, name: &str) -> bool
Returns whether this value is of the named type.
The default implementation checks against the value of self.type_name()
.
fn call_value(&self, ctx: &Context, args: &mut [Value]) -> Result<Value, Error>
Calls the value as a function.
The default implementation unconditionally returns an error.
fn size(&self) -> usize
Returns an estimate of the memory held by this value.
The result will be used in applying memory restrictions to executing code. The result MUST NOT change for the lifetime of the value.
Methods
impl dyn ForeignValue
[src]
pub fn is<T: ForeignValue>(&self) -> bool
[src]
Returns whether the contained value is of the given type.
pub fn downcast<T: ForeignValue>(bx: Box<Self>) -> Result<Box<T>, Box<Self>>
[src]
Attempts to downcast a Box<Trait>
to a concrete type.
pub fn downcast_rc<T: ForeignValue>(rc: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
[src]
Returns an owned Rc
reference to the contained value,
if it is of the given type.
pub fn downcast_ref<T: ForeignValue>(&self) -> Option<&T>
[src]
Returns a reference to the contained value, if it is of the given type.
pub fn downcast_mut<T: ForeignValue>(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the contained value, if it is of the given type.
Implementors
impl<F> ForeignValue for ForeignFn<F> where
F: Any + Fn(&Context, &mut [Value]) -> Result<Value, Error>,
[src]
F: Any + Fn(&Context, &mut [Value]) -> Result<Value, Error>,