diff options
Diffstat (limited to 'mingling_core/src/program/hook.rs')
| -rw-r--r-- | mingling_core/src/program/hook.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/mingling_core/src/program/hook.rs b/mingling_core/src/program/hook.rs index d422e12..edbf996 100644 --- a/mingling_core/src/program/hook.rs +++ b/mingling_core/src/program/hook.rs @@ -56,7 +56,18 @@ pub struct ProgramAnonymousHook { pub post_render: Option<fn(result: &RenderResult)>, /// Executes before the program ends - pub finish: Option<fn()>, + pub finish: Option<fn() -> i32>, +} + +impl<C> Program<C> +where + C: ProgramCollect<Enum = C>, +{ + /// Adds an anonymous hook to the program. The hook will be called at the appropriate + /// lifecycle events, but receives string representations instead of typed references. + pub fn with_hook_anonymous(&mut self, hook: ProgramAnonymousHook) { + self.anonymous_hooks.push(hook); + } } impl<C> Program<C> @@ -69,12 +80,6 @@ where self.hooks.push(hook); } - /// Adds an anonymous hook to the program. The hook will be called at the appropriate - /// lifecycle events, but receives string representations instead of typed references. - pub fn with_hook_anonymous(&mut self, hook: ProgramAnonymousHook) { - self.anonymous_hooks.push(hook); - } - pub(crate) fn run_hook_on_begin(&self) { if !self.user_context.run_hook { return; @@ -342,7 +347,7 @@ impl ProgramAnonymousHook { } /// Sets the handler for the `finish` event. - pub fn on_finish(mut self, handler: fn()) -> Self { + pub fn on_finish(mut self, handler: fn() -> i32) -> Self { let _ = self.finish.insert(handler); self } |
