use std::borrow::Cow;
use crate::{LayoutFn, LayoutRenderFn, PageFn, PageRenderFn, Path};
#[doc(hidden)]
#[derive(Debug, Clone)]
pub struct ModulePageFn {
module_path: &'static str,
pub(super) render: PageRenderFn,
}
impl ModulePageFn {
pub const fn new(module_path: &'static str, render: PageRenderFn) -> Self {
Self {
module_path,
render,
}
}
#[must_use]
pub fn into_page(self, path: Cow<'static, Path>) -> PageFn {
PageFn::new(path, self.render)
}
#[must_use]
pub fn module_path(&self) -> &'static str {
self.module_path
}
}
#[cfg(feature = "discover")]
inventory::collect!(ModulePageFn);
#[doc(hidden)]
#[derive(Debug, Clone)]
pub struct ModuleLayoutFn {
module_path: &'static str,
render: LayoutRenderFn,
}
impl ModuleLayoutFn {
pub const fn new(module_path: &'static str, render: LayoutRenderFn) -> Self {
Self {
module_path,
render,
}
}
#[must_use]
pub fn into_layout(self, path: Cow<'static, Path>) -> LayoutFn {
LayoutFn::new(path, self.render)
}
#[must_use]
pub fn module_path(&self) -> &'static str {
self.module_path
}
}
#[cfg(feature = "discover")]
inventory::collect!(ModuleLayoutFn);