Skip to content

Commit

Permalink
Load devices
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Jul 12, 2023
1 parent 0218f3a commit 6f33a43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions rust/agama-lib/src/storage/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ pub struct Device {
pub name: String,
}

impl From<String> for Device {
fn from(value: String) -> Self {
Self { name: value }
}
}

impl TryFrom<SettingObject> for Device {
type Error = &'static str;

Expand Down
5 changes: 3 additions & 2 deletions rust/agama-lib/src/storage/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ impl<'a> StorageStore<'a> {
})
}

// TODO: read the settings from the service
pub async fn load(&self) -> Result<StorageSettings, Box<dyn Error>> {
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<dyn Error>> {
Expand Down

0 comments on commit 6f33a43

Please sign in to comment.