pub struct ModuleId { /* private fields */ }Expand description
Identity of a module: its Rust type plus a readable name.
Two module values with the same ModuleId are the same module: the kernel
registers each id once (see Module::is_configured).
Implementations§
Source§impl ModuleId
impl ModuleId
Sourcepub fn of<M: ?Sized + 'static>() -> Self
pub fn of<M: ?Sized + 'static>() -> Self
The id of module type M, named after the short type name of M.
Sourcepub fn named<M: ?Sized + 'static>(name: &'static str) -> ModuleId
pub fn named<M: ?Sized + 'static>(name: &'static str) -> ModuleId
The id of module type M under name: two values of one type with
different names are two modules.
use navree_kernel::ModuleId;
struct PaymentsModule;
let upi = ModuleId::named::<PaymentsModule>("upi");
let cards = ModuleId::named::<PaymentsModule>("cards");
assert_ne!(upi, cards);
assert_eq!(upi.name(), "upi");
assert_eq!(upi.type_name(), cards.type_name());Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
The readable module name (the short type name, e.g. UsersModule).
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The full type path (navree_plugin_announcements::AnnouncementsModule),
from std::any::type_name: for reading and for the plugin checks, not
for matching in an app; it may change in any release.
use navree_kernel::ModuleId;
struct AnnouncementsModule;
let id = ModuleId::of::<AnnouncementsModule>();
assert_eq!(id.name(), "AnnouncementsModule");
assert!(id.type_name().ends_with("::AnnouncementsModule"));Trait Implementations§
impl Copy for ModuleId
impl Eq for ModuleId
Auto Trait Implementations§
impl Forget for ModuleId
impl Freeze for ModuleId
impl Move for ModuleId
impl RefUnwindSafe for ModuleId
impl Send for ModuleId
impl Sync for ModuleId
impl Unpin for ModuleId
impl UnsafeUnpin for ModuleId
impl UnwindSafe for ModuleId
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
Mutably borrows from an owned value. Read more