From dc7de16137303764c9300235568d2d4b88fd70d1 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 8 May 2024 15:21:02 -0700 Subject: [PATCH] daemon: Improve module naming --- src/bin/steamos-manager.rs | 6 +++--- src/{daemon.rs => daemon/mod.rs} | 14 ++++++++++---- src/{ => daemon}/root.rs | 0 src/{ => daemon}/user.rs | 0 src/lib.rs | 4 +--- 5 files changed, 14 insertions(+), 10 deletions(-) rename src/{daemon.rs => daemon/mod.rs} (88%) rename src/{ => daemon}/root.rs (100%) rename src/{ => daemon}/user.rs (100%) diff --git a/src/bin/steamos-manager.rs b/src/bin/steamos-manager.rs index 3be2ff4..75e7a60 100644 --- a/src/bin/steamos-manager.rs +++ b/src/bin/steamos-manager.rs @@ -8,7 +8,7 @@ use anyhow::Result; use clap::Parser; -use steamos_manager::{root, user}; +use steamos_manager::daemon; #[derive(Parser)] struct Args { @@ -21,8 +21,8 @@ struct Args { pub async fn main() -> Result<()> { let args = Args::parse(); if args.root { - root::daemon().await + daemon::root().await } else { - user::daemon().await + daemon::user().await } } diff --git a/src/daemon.rs b/src/daemon/mod.rs similarity index 88% rename from src/daemon.rs rename to src/daemon/mod.rs index 4fcccd5..1c42947 100644 --- a/src/daemon.rs +++ b/src/daemon/mod.rs @@ -17,7 +17,13 @@ use zbus::connection::Connection; use crate::sls::{LogLayer, LogReceiver}; use crate::{reload, Service}; -pub struct Daemon { +mod root; +mod user; + +pub use root::daemon as root; +pub use user::daemon as user; + +pub(crate) struct Daemon { services: JoinSet>, token: CancellationToken, sigterm: Signal, @@ -25,7 +31,7 @@ pub struct Daemon { } impl Daemon { - pub async fn new LookupSpan<'a>>( + pub(crate) async fn new LookupSpan<'a>>( subscriber: S, connection: Connection, ) -> Result { @@ -51,13 +57,13 @@ impl Daemon { Ok(daemon) } - pub fn add_service(&mut self, service: S) { + pub(crate) fn add_service(&mut self, service: S) { let token = self.token.clone(); self.services .spawn(async move { service.start(token).await }); } - pub async fn run(&mut self) -> Result<()> { + pub(crate) async fn run(&mut self) -> Result<()> { ensure!( !self.services.is_empty(), "Can't run a daemon with no services attached." diff --git a/src/root.rs b/src/daemon/root.rs similarity index 100% rename from src/root.rs rename to src/daemon/root.rs diff --git a/src/user.rs b/src/daemon/user.rs similarity index 100% rename from src/user.rs rename to src/daemon/user.rs diff --git a/src/lib.rs b/src/lib.rs index 73b5a7c..e62f6b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,6 @@ use tokio_util::sync::CancellationToken; use tracing::{info, warn}; mod cec; -mod daemon; mod ds_inhibit; mod error; mod hardware; @@ -26,9 +25,8 @@ mod sls; mod systemd; mod user_manager; +pub mod daemon; pub mod proxy; -pub mod root; -pub mod user; pub mod wifi; #[cfg(test)]