Trait ketos::value::ForeignValue [] [src]

pub trait ForeignValue: AnyValue + Debug {
    fn type_name(&self) -> &'static str;

    fn compare_to(&self, rhs: &ForeignValue) -> Result<Ordering, ExecError> { ... }
    fn compare_to_value(&self, rhs: &Value) -> Result<Ordering, ExecError> { ... }
    fn is_identical_to(&self, rhs: &ForeignValue) -> bool { ... }
    fn is_equal_to(&self, rhs: &ForeignValue) -> Result<bool, ExecError> { ... }
    fn is_equal_to_value(&self, rhs: &Value) -> Result<bool, ExecError> { ... }
    fn fmt_debug(&self, names: &NameStore, f: &mut Formatter) -> Result { ... }
    fn fmt_display(&self, names: &NameStore, f: &mut Formatter) -> Result { ... }
    fn is_type(&self, name: &str) -> bool { ... }
    fn call_value(&self,
                  ctx: &Context,
                  args: &mut [Value])
                  -> Result<Value, Error> { ... } fn size(&self) -> usize { ... } }

Represents a type of value defined outside the core interpreter.

Required Methods

Return the value's type name.

Provided Methods

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.

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.

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.

Tests for equality between two values of a foreign type.

The default implementation unconditionally returns an error.

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.

Format the value in debugging mode.

The default implementation uses the type's fmt::Debug representation.

Format the value in display mode.

The default implementation formats the value in debugging mode.

Returns whether this value is of the named type.

The default implementation checks against the value of self.type_name().

Calls the value as a function.

The default implementation unconditionally returns an error.

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 ForeignValue
[src]

Returns whether the contained value is of the given type.

Returns an owned Rc reference to the contained value, if it is os the given type.

Returns a reference to the contained value, if it is of the given type.

Returns a mutable reference to the contained value, if it is of the given type.

Implementors