pub struct ModuleId(/* private fields */);Expand description
Unique identifier for a loadable module.
Convention: Use kebab-case names like “lang-rust”, “feat-completion”.
§Static vs Dynamic IDs
Module IDs can be either:
- Static (
&'static str): For compile-time known modules, useModuleId::new() - Dynamic (
String): For runtime-generated modules, useModuleId::from_string()
Static IDs are preferred for performance (no allocation), but dynamic IDs allow for user-defined or plugin-loaded modules with arbitrary names.
§Example
use reovim_kernel::api::v1::ModuleId;
// Static ID (compile-time known)
let static_id = ModuleId::new("lang-rust");
// Dynamic ID (runtime generated)
let name = format!("user-plugin-{}", 42);
let dynamic_id = ModuleId::from_string(name);
// Both work the same way
assert_eq!(static_id.as_str(), "lang-rust");
assert_eq!(dynamic_id.as_str(), "user-plugin-42");Implementations§
Source§impl ModuleId
impl ModuleId
Sourcepub const fn new(id: &'static str) -> Self
pub const fn new(id: &'static str) -> Self
Create a new module identifier from a static string.
This is the preferred way to create module IDs for statically-known modules. It’s a const fn and involves no allocation.
Sourcepub fn from_string(id: String) -> Self
pub fn from_string(id: String) -> Self
Create a module identifier from an owned String.
Use this for dynamically-generated module IDs (e.g., user plugins, runtime-loaded modules with user-provided names).
Sourcepub const fn is_dynamic(&self) -> bool
pub const fn is_dynamic(&self) -> bool
Check if this is a dynamic (owned) ID.
Trait Implementations§
impl Eq for ModuleId
impl StructuralPartialEq for ModuleId
Auto Trait Implementations§
impl Freeze 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