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 from static strings.
This is the preferred way to create command IDs for statically-known commands. It’s a const fn and involves no allocation.
Sourcepub fn from_owned(module: ModuleId, name: String) -> Self
pub fn from_owned(module: ModuleId, name: String) -> Self
Create a command identifier from owned strings.
Use this for dynamically-generated command IDs (e.g., picker selections, FFI calls, manifest parsing).
Sourcepub fn from_qualified(qualified: String) -> Self
pub fn from_qualified(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.
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("editor:cursor-down".to_string());
assert_eq!(cmd.module().as_str(), "editor");
assert_eq!(cmd.name(), "cursor-down");Sourcepub fn name_owned(&self) -> Cow<'static, str>
pub fn name_owned(&self) -> Cow<'static, str>
Get the local name as an owned Cow.
Use this when you need a value that isn’t tied to the CommandId’s
lifetime (e.g., when calling .id().name_owned() on a temporary).