aboutsummaryrefslogtreecommitdiff
path: root/src/module.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-02 00:48:47 +0000
committerFuwn <[email protected]>2022-04-02 00:48:47 +0000
commit8869b6ef044aa42043f8e17ee0d56767730d56fc (patch)
tree465d58df7fd5ec125f7ebe9400e6b6d28ed8c7ff /src/module.rs
parentbuild(cargo): simplify example usage (diff)
downloadwindmark-8869b6ef044aa42043f8e17ee0d56767730d56fc.tar.xz
windmark-8869b6ef044aa42043f8e17ee0d56767730d56fc.zip
feat(router): stateful modules!
Diffstat (limited to 'src/module.rs')
-rw-r--r--src/module.rs30
1 files changed, 30 insertions, 0 deletions
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 <https://github.com/gemrest/windmark>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// 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<'_>) {}
+}