mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 17:32:21 -04:00
lib: Export some modules as pub
This commit is contained in:
parent
2977731fca
commit
f4247de8c1
4 changed files with 19 additions and 22 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
20
src/lib.rs
20
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<S: AsRef<str>>(path: S) -> PathBuf {
|
|||
.join(path.as_ref().trim_start_matches('/'))
|
||||
}
|
||||
|
||||
pub async fn write_synced<P: AsRef<Path>>(path: P, bytes: &[u8]) -> Result<()> {
|
||||
pub(crate) async fn write_synced<P: AsRef<Path>>(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<String> {
|
||||
pub(crate) fn read_comm(pid: u32) -> Result<String> {
|
||||
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<Option<u64>> {
|
||||
pub(crate) fn get_appid(pid: u32) -> Result<Option<u64>> {
|
||||
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('=') {
|
||||
|
|
12
src/wifi.rs
12
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<WifiBackend> {
|
||||
pub(crate) async fn get_wifi_backend() -> Result<WifiBackend> {
|
||||
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<WifiBackend> {
|
|||
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<WifiPowerManagement> {
|
||||
pub(crate) async fn get_wifi_power_management_state() -> Result<WifiPowerManagement> {
|
||||
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<WifiPowerManagement> {
|
|||
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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue