pub struct DeviceAlias {
pub alias: String,
pub serial: Option<String>,
pub name: Option<String>,
pub mac_address: Option<String>,
pub macos_uuid: Option<String>,
pub notes: Option<String>,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}Expand description
A cross-platform device alias that can store multiple identifiers.
This allows identifying the same physical device across different platforms and machines, where the identifier format varies.
§Example
use aranet_core::platform::DeviceAlias;
let alias = DeviceAlias::new("Living Room")
.with_serial("SN123456")
.with_name("Aranet4 12345")
.with_mac("AA:BB:CC:DD:EE:FF");
// Get the best identifier for the current platform
let id = alias.resolve();Fields§
§alias: StringUser-friendly name for this device.
serial: Option<String>Device serial number (most reliable cross-platform ID).
name: Option<String>Device name (e.g., “Aranet4 12345”).
mac_address: Option<String>Bluetooth MAC address (Linux/Windows).
macos_uuid: Option<String>CoreBluetooth UUID (macOS only).
notes: Option<String>Notes or description for this device.
created_at: Option<String>When this alias was created.
updated_at: Option<String>When this alias was last updated.
Implementations§
Source§impl DeviceAlias
impl DeviceAlias
Sourcepub fn new(alias: impl Into<String>) -> Self
pub fn new(alias: impl Into<String>) -> Self
Create a new device alias with the given user-friendly name.
Sourcepub fn with_serial(self, serial: impl Into<String>) -> Self
pub fn with_serial(self, serial: impl Into<String>) -> Self
Set the device serial number.
Sourcepub fn with_notes(self, notes: impl Into<String>) -> Self
pub fn with_notes(self, notes: impl Into<String>) -> Self
Set notes for this device.
Sourcepub fn resolve(&self) -> Option<String>
pub fn resolve(&self) -> Option<String>
Resolve the alias to a platform-appropriate identifier.
Resolution order:
- On macOS: macos_uuid → name → serial
- On Linux/Windows: mac_address → name → serial
Returns None if no suitable identifier is available.
Sourcepub fn matches(&self, identifier: &str) -> bool
pub fn matches(&self, identifier: &str) -> bool
Check if this alias matches a given identifier.
This checks against all stored identifiers (serial, name, MAC, UUID).
Sourcepub fn update_identifier(&mut self, identifier: &str)
pub fn update_identifier(&mut self, identifier: &str)
Update the platform-specific identifier.
Call this after connecting to a device to update the alias with the current platform’s identifier.
Trait Implementations§
Source§impl Clone for DeviceAlias
impl Clone for DeviceAlias
Source§fn clone(&self) -> DeviceAlias
fn clone(&self) -> DeviceAlias
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more