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§
sourcefn type_static() -> &'static strwhere
Self: Sized,
fn type_static() -> &'static strwhere
Self: Sized,
The Object’s type as a static string
sourcefn type_string(&self) -> KString
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.