lib: Export some modules as pub

This commit is contained in:
Vicki Pfau 2024-05-07 17:15:28 -07:00
parent 2977731fca
commit f4247de8c1
4 changed files with 19 additions and 22 deletions

View file

@ -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('=') {