Skip to content

Commit

Permalink
format rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 16, 2024
1 parent f8b4ca5 commit 3d536a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 11 additions & 8 deletions rust/agama-server/src/software/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
};
use agama_lib::{
error::ServiceError,
product::{Product, ProductClient, RegistrationRequirement, proxies::RegistrationProxy},
product::{proxies::RegistrationProxy, Product, ProductClient, RegistrationRequirement},
software::{
proxies::{Software1Proxy, SoftwareProductProxy},
Pattern, SelectedBy, SoftwareClient, UnknownSelectedBy,
Expand Down Expand Up @@ -49,9 +49,7 @@ pub struct SoftwareConfig {
/// It emits the Event::ProductChanged and Event::PatternsChanged events.
///
/// * `connection`: D-Bus connection to listen for events.
pub async fn software_streams(
dbus: zbus::Connection,
) -> Result<Streams, Error> {
pub async fn software_streams(dbus: zbus::Connection) -> Result<Streams, Error> {
let result: Streams = vec![
(
"patterns_changed",
Expand Down Expand Up @@ -118,7 +116,8 @@ async fn patterns_changed_stream(
Ok(stream)
}

async fn registration_requirement_changed_stream(dbus: zbus::Connection,
async fn registration_requirement_changed_stream(
dbus: zbus::Connection,
) -> Result<impl Stream<Item = Event>, Error> {
// TODO: move registration requirement to product in dbus and so just one event will be needed.
let proxy = RegistrationProxy::new(&dbus).await?;
Expand All @@ -128,15 +127,18 @@ async fn registration_requirement_changed_stream(dbus: zbus::Connection,
.then(|change| async move {
if let Ok(id) = change.get().await {
// unwrap is safe as possible numbers is send by our controlled dbus
return Some(Event::RegistrationRequirementChanged { requirement: id.try_into().unwrap() });
return Some(Event::RegistrationRequirementChanged {
requirement: id.try_into().unwrap(),
});
}
None
})
.filter_map(|e| e);
Ok(stream)
}

async fn registration_email_changed_stream(dbus: zbus::Connection,
async fn registration_email_changed_stream(
dbus: zbus::Connection,
) -> Result<impl Stream<Item = Event>, Error> {
let proxy = RegistrationProxy::new(&dbus).await?;
let stream = proxy
Expand All @@ -153,7 +155,8 @@ async fn registration_email_changed_stream(dbus: zbus::Connection,
Ok(stream)
}

async fn registration_code_changed_stream(dbus: zbus::Connection,
async fn registration_code_changed_stream(
dbus: zbus::Connection,
) -> Result<impl Stream<Item = Event>, Error> {
let proxy = RegistrationProxy::new(&dbus).await?;
let stream = proxy
Expand Down
4 changes: 1 addition & 3 deletions rust/agama-server/src/users/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ struct UsersState<'a> {
/// It emits the Event::RootPasswordChange, Event::RootSSHKeyChanged and Event::FirstUserChanged events.
///
/// * `connection`: D-Bus connection to listen for events.
pub async fn users_streams(
dbus: zbus::Connection,
) -> Result<Streams, Error> {
pub async fn users_streams(dbus: zbus::Connection) -> Result<Streams, Error> {
const FIRST_USER_ID: &str = "first_user";
const ROOT_PASSWORD_ID: &str = "root_password";
const ROOT_SSHKEY_ID: &str = "root_sshkey";
Expand Down
6 changes: 3 additions & 3 deletions rust/agama-server/src/web/event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::l10n::web::LocaleConfig;
use agama_lib::{
manager::InstallationPhase, progress::Progress, software::SelectedBy, users::FirstUser,
product::RegistrationRequirement,
manager::InstallationPhase, product::RegistrationRequirement, progress::Progress,
software::SelectedBy, users::FirstUser,
};
use serde::Serialize;
use std::collections::HashMap;
Expand All @@ -24,7 +24,7 @@ pub enum Event {
ProductChanged {
id: String,
},
RegistrationRequirementChanged{
RegistrationRequirementChanged {
requirement: RegistrationRequirement,
},
RegistrationChanged,
Expand Down

0 comments on commit 3d536a0

Please sign in to comment.