pub struct CommandId { /* private fields */ }Expand description
Namespaced command identifier.
Commands are identified by their owning module and a local name. This prevents naming conflicts between modules.
§Example
use reovim_kernel::api::v1::{CommandId, ModuleId};
let editor_module = ModuleId::new("editor");
let cursor_down = CommandId::new(editor_module.clone(), "cursor-down");
let cursor_up = CommandId::new(editor_module, "cursor-up");
assert_eq!(cursor_down.name(), "cursor-down");
assert_ne!(cursor_down, cursor_up);Implementations§
Source§impl CommandId
impl CommandId
Sourcepub const fn new(module: ModuleId, name: &'static str) -> Self
pub const fn new(module: ModuleId, name: &'static str) -> Self
Create a new command identifier.
Sourcepub fn from_qualified_leaked(qualified: String) -> Self
pub fn from_qualified_leaked(qualified: String) -> Self
Create a command identifier from a qualified string like “module:command”.
This method is intended for dynamic use cases like FFI where command IDs
are specified as strings at runtime. The strings are leaked to get
'static lifetime, so this should only be used for long-lived commands.
If the string doesn’t contain ‘:’, the entire string is treated as the command name with “unknown” as the module.
§Example
use reovim_kernel::api::v1::CommandId;
let cmd = CommandId::from_qualified_leaked("editor:cursor-down".to_string());
assert_eq!(cmd.module().as_str(), "editor");
assert_eq!(cmd.name(), "cursor-down");Trait Implementations§
impl Eq for CommandId
impl StructuralPartialEq for CommandId
Auto Trait Implementations§
impl Freeze for CommandId
impl RefUnwindSafe for CommandId
impl Send for CommandId
impl Sync for CommandId
impl Unpin for CommandId
impl UnsafeUnpin for CommandId
impl UnwindSafe for CommandId
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