pub struct CommandID {
pub command_id_to_uuid: HashMap<u16, String>,
pub uuid_to_commander: HashMap<String, String>,
pub command_ids: BTreeSet<u16>,
}Expand description
A structure to manage command IDs and their associated UUIDs. Command IDs are allocated from a pool of 0-255. When a command is finished, its ID is returned to the pool.
Fields§
§command_id_to_uuid: HashMap<u16, String>A HashMap mapping command IDs to UUID strings.
uuid_to_commander: HashMap<String, String>A HashMap mapping UUID strings to commander names.
command_ids: BTreeSet<u16>A BTreeSet of available command IDs.
Implementations§
Source§impl CommandID
impl CommandID
Sourcepub fn register_command(&mut self, uuid: &str, commander: &str, command_id: u16)
pub fn register_command(&mut self, uuid: &str, commander: &str, command_id: u16)
Registers a command with a given UUID, commander name, and command ID.
Sourcepub fn get_command_id(&mut self) -> u16
pub fn get_command_id(&mut self) -> u16
Retrieves and removes an available command ID from the pool.
Sourcepub fn finish_command(&mut self, command_id: u16) -> Option<String>
pub fn finish_command(&mut self, command_id: u16) -> Option<String>
Finishes a command by its ID, removing its associations and returning the UUID. The command ID is returned to the pool of available IDs.
Sourcepub fn get_uuid(&self, command_id: u16) -> Option<&String>
pub fn get_uuid(&self, command_id: u16) -> Option<&String>
Retrieves the UUID associated with a given command ID, if it exists.
Sourcepub fn is_command_id_in_use(&self, command_id: u16) -> bool
pub fn is_command_id_in_use(&self, command_id: u16) -> bool
Checks if a command ID is currently in use.
Sourcepub fn get_commander(&self, uuid: &str) -> Option<&String>
pub fn get_commander(&self, uuid: &str) -> Option<&String>
Retrieves the commander name associated with a given UUID, if it exists.