pub struct DeviceStore { /* private fields */ }Expand description
Handle to the device registry table. Cheaply cloneable (wraps an Arc).
Implementations§
Source§impl DeviceStore
impl DeviceStore
Sourcepub fn open(path: PathBuf) -> Result<Self>
pub fn open(path: PathBuf) -> Result<Self>
Open (or create) the store at a specific path and run migrations. The host
computes the path (~/.ryu/hardware.db); this crate never reaches Core’s
paths module, so it has zero dependency on apps/core.
Sourcepub async fn insert(&self, record: DeviceRecord) -> Result<DeviceRecord>
pub async fn insert(&self, record: DeviceRecord) -> Result<DeviceRecord>
Insert a freshly paired device (or replace one with the same id — a re-pair rotates the token), returning the stored record.
Sourcepub async fn get(&self, device_id: &str) -> Result<Option<DeviceRecord>>
pub async fn get(&self, device_id: &str) -> Result<Option<DeviceRecord>>
Look up a device by id.
Sourcepub async fn list(&self) -> Result<Vec<DeviceRecord>>
pub async fn list(&self) -> Result<Vec<DeviceRecord>>
List all paired devices, newest first (drives GET /api/hardware/devices).
Sourcepub async fn verify_token(&self, device_id: &str, token: &str) -> Result<bool>
pub async fn verify_token(&self, device_id: &str, token: &str) -> Result<bool>
Verify a raw Bearer token against a device’s stored hash. Returns true
only when the device exists and the hash matches.
Sourcepub async fn update(
&self,
device_id: &str,
name: Option<String>,
prefs: Option<Value>,
) -> Result<bool>
pub async fn update( &self, device_id: &str, name: Option<String>, prefs: Option<Value>, ) -> Result<bool>
Update mutable fields (name/prefs) for PATCH. A None leaves the field
unchanged. Returns true when a row was touched.
Sourcepub async fn touch(
&self,
device_id: &str,
battery_pct: Option<i32>,
) -> Result<()>
pub async fn touch( &self, device_id: &str, battery_pct: Option<i32>, ) -> Result<()>
Mark a device seen now and record latest battery (from telemetry). A
None battery leaves the stored value unchanged.
Trait Implementations§
Source§impl Clone for DeviceStore
impl Clone for DeviceStore
Source§fn clone(&self) -> DeviceStore
fn clone(&self) -> DeviceStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more