Trait tokay::value::Object

source ·
pub trait Object: AnyBoxedObject + CloneBoxedObject + PartialEqBoxedObject + PartialOrdBoxedObject + Any + Debug {
Show 19 methods // Required method fn name(&self) -> &'static str; // Provided methods fn id(&self) -> usize { ... } fn severity(&self) -> u8 { ... } fn is(&self, name: &str) -> bool { ... } fn repr(&self) -> String { ... } fn is_void(&self) -> bool { ... } fn is_true(&self) -> bool { ... } fn to_i64(&self) -> Result<i64, String> { ... } fn to_f64(&self) -> Result<f64, String> { ... } fn to_usize(&self) -> Result<usize, String> { ... } fn to_string(&self) -> String { ... } fn to_bigint(&self) -> Result<BigInt, String> { ... } fn is_callable(&self, _without_arguments: bool) -> bool { ... } fn is_consuming(&self) -> bool { ... } fn is_nullable(&self) -> bool { ... } fn is_mutable(&self) -> bool { ... } fn is_hashable(&self) -> bool { ... } fn call( &self, _context: Option<&mut Context<'_, '_, '_, '_>>, _args: Vec<RefValue>, _nargs: Option<Dict> ) -> Result<Accept, Reject> { ... } fn call_direct( &self, context: &mut Context<'_, '_, '_, '_>, args: usize, nargs: Option<Dict> ) -> Result<Accept, Reject> { ... }
}
Expand description

Describes an interface to a callable object.

Required Methods§

source

fn name(&self) -> &'static str

Object type name.

Provided Methods§

source

fn id(&self) -> usize

Object ID (unique memory address)

source

fn severity(&self) -> u8

Object severity

source

fn is(&self, name: &str) -> bool

Check for value type name.

source

fn repr(&self) -> String

Object representation in Tokay code

source

fn is_void(&self) -> bool

Object as void

source

fn is_true(&self) -> bool

Object as bool

source

fn to_i64(&self) -> Result<i64, String>

Object as i64

source

fn to_f64(&self) -> Result<f64, String>

Object as f64

source

fn to_usize(&self) -> Result<usize, String>

Object as usize

source

fn to_string(&self) -> String

Object as String

source

fn to_bigint(&self) -> Result<BigInt, String>

Object as BigInt

source

fn is_callable(&self, _without_arguments: bool) -> bool

Check whether the object is callable.

source

fn is_consuming(&self) -> bool

Check whether the object is consuming

source

fn is_nullable(&self) -> bool

Check whether the object is nullable

source

fn is_mutable(&self) -> bool

Check whether the object is mutable in itself.

Most objects are not mutable, they represent a single value that doesn’t change. For example, Tokay’s str-objects are not mutable in itself, str-methods do always return a new str-object. This is different for list or dict, they are mutable in theirself.

The mutability setting changes stack behavior: Objects are (mostly) referenced when they are mutable, and copied when they are imutable.

source

fn is_hashable(&self) -> bool

Check whether the object is hashable.

By default, this depends on is_mutable(), but could also be customized. This defines if an object can be used as key in dicts.

source

fn call( &self, _context: Option<&mut Context<'_, '_, '_, '_>>, _args: Vec<RefValue>, _nargs: Option<Dict> ) -> Result<Accept, Reject>

Call object with optional context, arguments and named arguments set.

source

fn call_direct( &self, context: &mut Context<'_, '_, '_, '_>, args: usize, nargs: Option<Dict> ) -> Result<Accept, Reject>

Directly call object with a given stack configuration.

This leads in lesser stack operations as previously pushed stack items can be used directly as local variables without change, which is the case in parselets.

Implementors§