pub struct CallbackSignature<A, R>where
A: IntoLuaMulti,
R: FromLuaMulti,{ /* 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<A, R> CallbackSignature<A, R>where
A: IntoLuaMulti,
R: FromLuaMulti,
impl<A, R> CallbackSignature<A, R>where
A: IntoLuaMulti,
R: FromLuaMulti,
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)
pub fn raise_error_if_allow_multiple(&self) -> Result<()>
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.
pub fn name(&self) -> &str
pub fn decorated_name(&self) -> String
Auto Trait Implementations§
impl<A, R> Freeze for CallbackSignature<A, R>
impl<A, R> RefUnwindSafe for CallbackSignature<A, R>where
A: RefUnwindSafe,
R: RefUnwindSafe,
impl<A, R> Send for CallbackSignature<A, R>
impl<A, R> Sync for CallbackSignature<A, R>
impl<A, R> Unpin for CallbackSignature<A, R>
impl<A, R> UnwindSafe for CallbackSignature<A, R>where
A: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more