pub trait Object: Any + ToAny + OpaqueClone + RawPointer + LockImmutable {
Show 13 methods fn technetium_type_name(&self) -> String; fn technetium_clone(
        &self,
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<ObjectRef> { ... }
fn technetium_hash(&self) -> Option<u64> { ... }
fn to_string(&self) -> RuntimeResult<String> { ... }
fn get_attr(
        &self,
        _attr: String,
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<ObjectRef> { ... }
fn set_attr(
        &self,
        _attr: String,
        _val: ObjectRef,
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<()> { ... }
fn call_method(
        &self,
        method: &str,
        _args: &[ObjectRef],
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<ObjectRef> { ... }
fn call(
        &self,
        _args: &[ObjectRef],
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<ObjectRef> { ... }
fn make_iter(
        &self,
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<ObjectRef> { ... }
fn take_iter(
        &self,
        _context: &mut RuntimeContext<'_>
    ) -> RuntimeResult<Option<ObjectRef>> { ... }
fn truthy(&self) -> bool { ... }
fn technetium_eq(&self, _other: ObjectRef) -> Option<bool> { ... }
fn ref_eq(&self, other: ObjectRef) -> bool { ... }
}
Expand description

The primary trait for objects in technetium.

Types that implement Object should be of the form ObjectCell<T> for some T. This will give all of the requirement subtraits for free.

Required methods

A type name for an object.

Conventions are that type names are all lowercase, and use parentheses to denote “sub-types” (for example: “iterator(list)”)

This function should not fail, so should return a set value.

Provided methods

Create a deep clone of an object. This is primarily used in the clone function in technetium

Hash an object. This is not required, so the default implementation always returns None.

In implementing a hash, it’s important that x == y implies that x.technetium_hash() == y.technetium_hash() to avoid logic errors.

Note that ObjectRef does not implement Hash in Rust, but HashableObjectRef does. See the docs for HashableObjectRef for more information

Convert an object to a String.

Get an attribute of an object

Set an attribute of an object

Call a given method of an object

Call a given object as a function.

Create an iterator over an object. This is used for initializing for loops.

Take from this object, assuming it is an iterator. This is used for stepping through for loops.

Determine whether an object is “truthy” (whether it should be treated as true when used as a boolean)

Equal-as-value (like == in Python, or .equals() in Java) Should return None if self cannot reasonably determine if other is equal or not. Typical implementations will usually only return Some(value) if they can definitively answer, And will quickly answer None otherwise. This allows equality to be reflexive by calling other.technetium_eq in case the answer is None.

Equal-as-reference (like is in Python, or == in Java)

This is treated as a fallback in the Eq implementation for ObjectRef, primarily for sets and dictionaries

Trait Implementations

Formats the value using the given formatter. Read more

Implementors