diff --git a/src/bin/steamos-manager.rs b/src/bin/steamos-manager.rs index b6d9303..3be2ff4 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::{RootDaemon, UserDaemon}; +use steamos_manager::{root, user}; #[derive(Parser)] struct Args { @@ -21,8 +21,8 @@ struct Args { pub async fn main() -> Result<()> { let args = Args::parse(); if args.root { - RootDaemon().await + root::daemon().await } else { - UserDaemon().await + user::daemon().await } } diff --git a/src/bin/steamosctl.rs b/src/bin/steamosctl.rs index 043f7ff..8726729 100644 --- a/src/bin/steamosctl.rs +++ b/src/bin/steamosctl.rs @@ -10,7 +10,8 @@ use clap::{Parser, Subcommand}; use itertools::Itertools; use std::ops::Deref; use std::str::FromStr; -use steamos_manager::{ManagerProxy, WifiBackend}; +use steamos_manager::proxy::ManagerProxy; +use steamos_manager::wifi::WifiBackend; use zbus::fdo::PropertiesProxy; use zbus::names::InterfaceName; use zbus::{zvariant, Connection}; diff --git a/src/lib.rs b/src/lib.rs index 670bcc5..4ba36d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,22 +21,18 @@ mod hardware; mod manager; mod power; mod process; -mod proxy; -mod root; mod sls; mod systemd; -mod user; mod user_manager; -mod wifi; + +pub mod proxy; +pub mod root; +pub mod user; +pub mod wifi; #[cfg(test)] mod testing; -pub use proxy::ManagerProxy; -pub use root::daemon as RootDaemon; -pub use user::daemon as UserDaemon; -pub use wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement}; - const API_VERSION: u32 = 8; pub trait Service @@ -85,18 +81,18 @@ pub fn path>(path: S) -> PathBuf { .join(path.as_ref().trim_start_matches('/')) } -pub async fn write_synced>(path: P, bytes: &[u8]) -> Result<()> { +pub(crate) async fn write_synced>(path: P, bytes: &[u8]) -> Result<()> { let mut file = File::create(path.as_ref()).await?; file.write_all(bytes).await?; Ok(file.sync_data().await?) } -pub fn read_comm(pid: u32) -> Result { +pub(crate) fn read_comm(pid: u32) -> Result { let comm = std::fs::read_to_string(path(format!("/proc/{}/comm", pid)))?; Ok(comm.trim_end().to_string()) } -pub fn get_appid(pid: u32) -> Result> { +pub(crate) fn get_appid(pid: u32) -> Result> { let environ = std::fs::read_to_string(path(format!("/proc/{}/environ", pid)))?; for env_var in environ.split('\0') { let (key, value) = match env_var.split_once('=') { diff --git a/src/wifi.rs b/src/wifi.rs index 2daf3ae..523a3a9 100644 --- a/src/wifi.rs +++ b/src/wifi.rs @@ -124,7 +124,7 @@ impl fmt::Display for WifiBackend { } } -pub async fn setup_iwd_config(want_override: bool) -> std::io::Result<()> { +pub(crate) async fn setup_iwd_config(want_override: bool) -> std::io::Result<()> { // Copy override.conf file into place or out of place depending // on install value @@ -174,7 +174,7 @@ async fn start_tracing(buffer_size: u32) -> Result<()> { .await } -pub async fn set_wifi_debug_mode( +pub(crate) async fn set_wifi_debug_mode( mode: WifiDebugMode, buffer_size: u32, should_trace: bool, @@ -225,7 +225,7 @@ pub async fn set_wifi_debug_mode( Ok(()) } -pub async fn get_wifi_backend() -> Result { +pub(crate) async fn get_wifi_backend() -> Result { let wifi_backend_contents = fs::read_to_string(path(WIFI_BACKEND_PATH)) .await? .trim() @@ -240,11 +240,11 @@ pub async fn get_wifi_backend() -> Result { bail!("WiFi backend not found in config"); } -pub async fn set_wifi_backend(backend: WifiBackend) -> Result<()> { +pub(crate) async fn set_wifi_backend(backend: WifiBackend) -> Result<()> { run_script("/usr/bin/steamos-wifi-set-backend", &[backend.to_string()]).await } -pub async fn get_wifi_power_management_state() -> Result { +pub(crate) async fn get_wifi_power_management_state() -> Result { let output = script_output("/usr/bin/iwconfig", &["wlan0"]).await?; for line in output.lines() { return Ok(match line.trim() { @@ -256,7 +256,7 @@ pub async fn get_wifi_power_management_state() -> Result { bail!("Failed to query power management state") } -pub async fn set_wifi_power_management_state(state: WifiPowerManagement) -> Result<()> { +pub(crate) async fn set_wifi_power_management_state(state: WifiPowerManagement) -> Result<()> { let state = match state { WifiPowerManagement::Disabled => "off", WifiPowerManagement::Enabled => "on",