Struct config::CallbackSignature
source · pub struct CallbackSignature<'lua, A, R>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,{ /* private fields */ }
Expand description
CallbackSignature is a bit sugar to aid with statically typing event callback function invocation.
The idea is that you declare a signature instance that is typed with its argument tuple (A), and its return type tuple (R).
The signature instance can then be used to invoke the callback by name.
The register method allows pre-registering events so that kumo.on
can reason about them better. The main function enabled by this is
allow_multiple
; when that is set to true, kumo.on
will allow
recording multiple callback instances, calling them in sequence
until one of them returns a value.
Implementations§
source§impl<'lua, A, R> CallbackSignature<'lua, A, R>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
impl<'lua, A, R> CallbackSignature<'lua, A, R>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
pub fn new<S: Into<Cow<'static, str>>>(name: S) -> Self
sourcepub fn new_with_multiple<S: Into<Cow<'static, str>>>(name: S) -> Self
pub fn new_with_multiple<S: Into<Cow<'static, str>>>(name: S) -> Self
Make sure that you call .register() on this from eg: mod_kumo::register in order for it to be instantiated and visible to the config loader
pub fn register(&self)
sourcepub fn allow_multiple(&self) -> bool
pub fn allow_multiple(&self) -> bool
Return true if this signature allows multiple instances to be registered and called.