Skip to content

Commit

Permalink
Updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 26, 2024
1 parent 686a23d commit 02bdac2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rust/agama-lib/src/network/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub enum DeviceType {
Bridge = 6,
}

// For now this mirrors NetworkManager, because it was less mental work than coming up with
// what exactly Agama needs. Expected to be adapted.
#[derive(Debug, Default, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum DeviceState {
Expand Down
9 changes: 5 additions & 4 deletions rust/agama-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ impl NetworkState {
}

pub fn remove_device(&mut self, name: &str) -> Result<(), NetworkStateError> {
// TODO: return an error if the device does not exist
if let Some(position) = self.devices.iter().position(|d| &d.name == name) {
self.devices.remove(position);
}
let Some(position) = self.devices.iter().position(|d| &d.name == name) else {
return Err(NetworkStateError::UnknownDevice(name.to_string()));
};

self.devices.remove(position);
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion rust/agama-server/src/network/nm/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl<'a> NetworkManagerClient<'a> {
{
devs.push(device);
} else {
tracing::warn!("Ignoring network device: ");
tracing::warn!("Ignoring network device on path {}", &path);
}
}

Expand Down

0 comments on commit 02bdac2

Please sign in to comment.