From 8869b6ef044aa42043f8e17ee0d56767730d56fc Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 2 Apr 2022 00:48:47 +0000 Subject: feat(router): stateful modules! --- src/module.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/module.rs (limited to 'src/module.rs') diff --git a/src/module.rs b/src/module.rs new file mode 100644 index 0000000..0d2d2f5 --- /dev/null +++ b/src/module.rs @@ -0,0 +1,30 @@ +// This file is part of Windmark . +// Copyright (C) 2022-2022 Fuwn +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// Copyright (C) 2022-2022 Fuwn +// SPDX-License-Identifier: GPL-3.0-only + +use crate::{returnable::CallbackContext, Router}; + +pub trait Module { + /// Called right after the module is attached. + fn on_attach(&mut self, _: &mut Router) {} + + /// Called before a route is mounted. + fn on_pre_route(&mut self, _: CallbackContext<'_>) {} + + /// Called after a route is mounted. + fn on_post_route(&mut self, _: CallbackContext<'_>) {} +} -- cgit v1.2.3