pub struct AliasStore { /* private fields */ }Expand description
An in-memory store for device aliases.
This provides a simple way to manage device aliases at runtime. For persistent storage, serialize the aliases to a file.
§Thread Safety
This store is thread-safe and can be shared across tasks.
§Example
use aranet_core::platform::{AliasStore, DeviceAlias};
let store = AliasStore::new();
// Add an alias
let alias = DeviceAlias::new("Kitchen")
.with_name("Aranet4 12345");
store.add(alias);
// Find by alias name
if let Some(alias) = store.get("Kitchen") {
println!("Found: {:?}", alias.resolve());
}Implementations§
Source§impl AliasStore
impl AliasStore
Sourcepub fn add(&self, alias: DeviceAlias)
pub fn add(&self, alias: DeviceAlias)
Add or update an alias in the store.
Sourcepub fn get(&self, alias_name: &str) -> Option<DeviceAlias>
pub fn get(&self, alias_name: &str) -> Option<DeviceAlias>
Get an alias by its user-friendly name.
Sourcepub fn remove(&self, alias_name: &str) -> Option<DeviceAlias>
pub fn remove(&self, alias_name: &str) -> Option<DeviceAlias>
Remove an alias by name.
Sourcepub fn find_by_identifier(&self, identifier: &str) -> Option<DeviceAlias>
pub fn find_by_identifier(&self, identifier: &str) -> Option<DeviceAlias>
Find an alias by any of its identifiers.
Sourcepub fn all(&self) -> Vec<DeviceAlias>
pub fn all(&self) -> Vec<DeviceAlias>
Get all aliases.
Trait Implementations§
Source§impl Debug for AliasStore
impl Debug for AliasStore
Source§impl Default for AliasStore
impl Default for AliasStore
Source§fn default() -> AliasStore
fn default() -> AliasStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for AliasStore
impl RefUnwindSafe for AliasStore
impl Send for AliasStore
impl Sync for AliasStore
impl Unpin for AliasStore
impl UnwindSafe for AliasStore
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