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§
Provided Methods§
sourcefn is_callable(&self, _without_arguments: bool) -> bool
fn is_callable(&self, _without_arguments: bool) -> bool
Check whether the object is callable.
sourcefn is_consuming(&self) -> bool
fn is_consuming(&self) -> bool
Check whether the object is consuming
sourcefn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
Check whether the object is nullable
sourcefn is_mutable(&self) -> bool
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.
sourcefn is_hashable(&self) -> bool
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.
sourcefn call(
&self,
_context: Option<&mut Context<'_, '_, '_, '_>>,
_args: Vec<RefValue>,
_nargs: Option<Dict>
) -> Result<Accept, Reject>
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.
sourcefn call_direct(
&self,
context: &mut Context<'_, '_, '_, '_>,
args: usize,
nargs: Option<Dict>
) -> Result<Accept, Reject>
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.