From 6f33a43fef4a65d2326c4de39ca27447571f7b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 12 Jul 2023 12:04:09 +0100 Subject: [PATCH] Load devices --- rust/agama-lib/src/storage/settings.rs | 6 ++++++ rust/agama-lib/src/storage/store.rs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rust/agama-lib/src/storage/settings.rs b/rust/agama-lib/src/storage/settings.rs index 1e208be46b..4c3d2ff488 100644 --- a/rust/agama-lib/src/storage/settings.rs +++ b/rust/agama-lib/src/storage/settings.rs @@ -25,6 +25,12 @@ pub struct Device { pub name: String, } +impl From for Device { + fn from(value: String) -> Self { + Self { name: value } + } +} + impl TryFrom for Device { type Error = &'static str; diff --git a/rust/agama-lib/src/storage/store.rs b/rust/agama-lib/src/storage/store.rs index 10c013cbdc..bf8cd0263c 100644 --- a/rust/agama-lib/src/storage/store.rs +++ b/rust/agama-lib/src/storage/store.rs @@ -18,9 +18,10 @@ impl<'a> StorageStore<'a> { }) } - // TODO: read the settings from the service pub async fn load(&self) -> Result> { - Ok(Default::default()) + let names = self.storage_client.candidate_devices().await?; + let devices = names.into_iter().map(|n| n.into()).collect(); + Ok(StorageSettings { devices, ..Default::default() }) } pub async fn store(&self, settings: &StorageSettings) -> Result<(), Box> {