Skip to content

Commit 560165c

Browse files
committed
Remove reduntant types
1 parent 0d38fbf commit 560165c

File tree

8 files changed

+33
-56
lines changed

8 files changed

+33
-56
lines changed

rust/agama-server/src/network/web.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
//! This module implements the web API for the network module.
2222
23-
use crate::{error::Error, web::EventsSender};
23+
use crate::error::Error;
2424
use anyhow::Context;
2525
use axum::{
2626
extract::{Path, State},
@@ -33,7 +33,7 @@ use uuid::Uuid;
3333

3434
use agama_lib::{
3535
error::ServiceError,
36-
event,
36+
event, http,
3737
network::{
3838
error::NetworkStateError,
3939
model::{AccessPoint, Connection, Device, GeneralState},
@@ -85,7 +85,7 @@ struct NetworkServiceState {
8585
/// * `events`: sending-half of the broadcast channel.
8686
pub async fn network_service<T: Adapter + Send + Sync + 'static>(
8787
adapter: T,
88-
events: EventsSender,
88+
events: http::event::Sender,
8989
) -> Result<Router, ServiceError> {
9090
let network = NetworkSystem::new(adapter);
9191
// FIXME: we are somehow abusing ServiceError. The HTTP/JSON API should have its own

rust/agama-server/src/software/web.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@
2727
2828
use crate::{
2929
error::Error,
30-
web::{
31-
common::{service_status_router, EventStreams, ProgressClient, ProgressRouterBuilder},
32-
EventsReceiver,
33-
},
30+
web::common::{service_status_router, EventStreams, ProgressClient, ProgressRouterBuilder},
3431
};
3532

3633
use agama_lib::{
3734
error::ServiceError,
3835
event,
39-
http::{Event, EventPayload},
36+
http::{self, Event, EventPayload},
4037
product::{proxies::RegistrationProxy, Product, ProductClient},
4138
software::{
4239
model::{
@@ -221,7 +218,7 @@ fn reason_to_selected_by(
221218
/// * `events`: channel to listen for events.
222219
/// * `products`: list of products (shared behind a mutex).
223220
pub async fn receive_events(
224-
mut events: EventsReceiver,
221+
mut events: http::event::Receiver,
225222
products: Arc<RwLock<Vec<Product>>>,
226223
config: Arc<RwLock<Option<SoftwareConfig>>>,
227224
client: ProductClient<'_>,
@@ -265,7 +262,7 @@ pub async fn receive_events(
265262
/// Sets up and returns the axum service for the software module.
266263
pub async fn software_service(
267264
dbus: zbus::Connection,
268-
events: EventsReceiver,
265+
events: http::event::Receiver,
269266
progress: ProgressClient,
270267
) -> Result<Router, ServiceError> {
271268
const DBUS_SERVICE: &str = "org.opensuse.Agama.Software1";

rust/agama-server/src/web.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ mod auth;
4747
pub mod common;
4848
mod config;
4949
pub mod docs;
50-
mod event;
5150
mod http;
5251
mod service;
5352
mod state;
5453
mod ws;
5554

56-
use agama_lib::{connection, error::ServiceError, http::Event};
55+
use agama_lib::{
56+
connection,
57+
error::ServiceError,
58+
http::event::{self, Event},
59+
};
5760
use common::ProgressService;
5861
pub use config::ServiceConfig;
59-
pub use event::{EventsReceiver, EventsSender};
6062
pub use service::MainServiceBuilder;
6163
use std::path::Path;
6264
use tokio_stream::{StreamExt, StreamMap};
@@ -69,7 +71,7 @@ use tokio_stream::{StreamExt, StreamMap};
6971
/// * `web_ui_dir`: public directory containing the web UI.
7072
pub async fn service<P>(
7173
config: ServiceConfig,
72-
events: EventsSender,
74+
events: event::Sender,
7375
dbus: zbus::Connection,
7476
web_ui_dir: P,
7577
) -> Result<Router, ServiceError>
@@ -116,7 +118,7 @@ where
116118
/// The events are sent to the `events` channel.
117119
///
118120
/// * `events`: channel to send the events to.
119-
pub async fn run_monitor(events: EventsSender) -> Result<(), ServiceError> {
121+
pub async fn run_monitor(events: event::Sender) -> Result<(), ServiceError> {
120122
let connection = connection().await?;
121123
tokio::spawn(run_events_monitor(connection, events.clone()));
122124

@@ -127,7 +129,7 @@ pub async fn run_monitor(events: EventsSender) -> Result<(), ServiceError> {
127129
///
128130
/// * `connection`: D-Bus connection.
129131
/// * `events`: channel to send the events to.
130-
async fn run_events_monitor(dbus: zbus::Connection, events: EventsSender) -> Result<(), Error> {
132+
async fn run_events_monitor(dbus: zbus::Connection, events: event::Sender) -> Result<(), Error> {
131133
let mut stream = StreamMap::new();
132134

133135
stream.insert("manager", manager_stream(dbus.clone()).await?);

rust/agama-server/src/web/common/progress.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@
3535
//!
3636
//! At this point, it only handles the progress that are exposed through D-Bus.
3737
38-
use crate::web::EventsSender;
3938
use agama_lib::{
4039
event,
41-
http::Event,
40+
http::{self, Event},
4241
progress::{Progress, ProgressSequence},
4342
proxies::{ProgressChanged, ProgressProxy},
4443
};
@@ -77,7 +76,7 @@ pub enum ProgressCommand {
7776
pub struct ProgressService {
7877
cache: HashMap<String, ProgressSequence>,
7978
commands: mpsc::Receiver<ProgressCommand>,
80-
events: EventsSender,
79+
events: http::event::Sender,
8180
dbus: zbus::Connection,
8281
}
8382

@@ -88,7 +87,7 @@ impl ProgressService {
8887
///
8988
/// * Commands from a client ([ProgressClient]).
9089
/// * Relevant events from D-Bus.
91-
pub async fn start(dbus: zbus::Connection, events: EventsSender) -> ProgressClient {
90+
pub async fn start(dbus: zbus::Connection, events: http::event::Sender) -> ProgressClient {
9291
let (tx, rx) = mpsc::channel(4);
9392
let mut service = ProgressService {
9493
cache: HashMap::new(),

rust/agama-server/src/web/event.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

rust/agama-server/src/web/service.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// find current contact information at www.suse.com.
2020

2121
use super::http::{login, login_from_query, logout, session};
22-
use super::{config::ServiceConfig, state::ServiceState, EventsSender};
23-
use agama_lib::auth::TokenClaims;
22+
use super::{config::ServiceConfig, state::ServiceState};
23+
use agama_lib::{auth::TokenClaims, http};
2424
use axum::http::HeaderValue;
2525
use axum::middleware::Next;
2626
use axum::{
@@ -55,7 +55,7 @@ use tracing::Span;
5555
/// * A number of authenticated services that are added using the `add_service` function.
5656
pub struct MainServiceBuilder {
5757
config: ServiceConfig,
58-
events: EventsSender,
58+
events: http::event::Sender,
5959
api_router: Router<ServiceState>,
6060
public_dir: PathBuf,
6161
}
@@ -65,7 +65,7 @@ impl MainServiceBuilder {
6565
///
6666
/// * `events`: channel to send events through the WebSocket.
6767
/// * `public_dir`: path to the public directory.
68-
pub fn new<P>(events: EventsSender, public_dir: P) -> Self
68+
pub fn new<P>(events: http::event::Sender, public_dir: P) -> Self
6969
where
7070
P: AsRef<Path>,
7171
{

rust/agama-server/src/web/state.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
//! Implements the web service state.
2222
23-
use super::{config::ServiceConfig, EventsSender};
23+
use super::config::ServiceConfig;
24+
use agama_lib::http;
2425
use std::path::PathBuf;
2526

2627
/// Web service state.
@@ -29,6 +30,6 @@ use std::path::PathBuf;
2930
#[derive(Clone)]
3031
pub struct ServiceState {
3132
pub config: ServiceConfig,
32-
pub events: EventsSender,
33+
pub events: http::event::Sender,
3334
pub public_dir: PathBuf,
3435
}

rust/agama-server/src/web/ws.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
//! Implements the websocket handling.
2222
23-
use std::sync::Arc;
24-
25-
use super::{state::ServiceState, EventsSender};
26-
use agama_lib::auth::ClientId;
23+
use super::state::ServiceState;
24+
use agama_lib::{auth::ClientId, http};
2725
use axum::{
2826
extract::{
2927
ws::{Message, WebSocket},
@@ -32,6 +30,7 @@ use axum::{
3230
response::IntoResponse,
3331
Extension,
3432
};
33+
use std::sync::Arc;
3534

3635
pub async fn ws_handler(
3736
State(state): State<ServiceState>,
@@ -41,7 +40,11 @@ pub async fn ws_handler(
4140
ws.on_upgrade(move |socket| handle_socket(socket, state.events, client_id))
4241
}
4342

44-
async fn handle_socket(mut socket: WebSocket, events: EventsSender, client_id: Arc<ClientId>) {
43+
async fn handle_socket(
44+
mut socket: WebSocket,
45+
events: http::event::Sender,
46+
client_id: Arc<ClientId>,
47+
) {
4548
let mut rx = events.subscribe();
4649

4750
let conn_event = agama_lib::event!(ClientConnected, client_id.as_ref());

0 commit comments

Comments
 (0)