Trait koto_runtime::KotoType

source ·
pub trait KotoType {
    // Required methods
    fn type_static() -> &'static str
       where Self: Sized;
    fn type_string(&self) -> KString;
}
Expand description

A trait for specifying a Koto object’s type

Using #[derive(KotoType)] is recommended.

Required Methods§

source

fn type_static() -> &'static str
where Self: Sized,

The Object’s type as a static string

source

fn type_string(&self) -> KString

The type of the Object as a KString

This should defer to the type returned by KotoType::type_static, and will be called whenever the object’s type is needed by the runtime, e.g. when a script calls koto.type, so caching the result is a good idea. #[derive(KotoType)] takes care of the details here.

Implementors§