From 450541b2bd29c9332d8aeeb98a33d7e7214db2cf Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 26 Jun 2024 19:38:12 -0700 Subject: [PATCH] Import a few more zbus things to reduce namespace line length --- src/manager/root.rs | 10 +++++----- src/manager/user.rs | 14 +++++++------- src/process.rs | 10 +++++----- src/sls/ftrace.rs | 3 +-- src/systemd.rs | 4 ++-- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/manager/root.rs b/src/manager/root.rs index c065ba7..aeea2f0 100644 --- a/src/manager/root.rs +++ b/src/manager/root.rs @@ -12,7 +12,7 @@ use tokio::fs::File; use tokio::sync::mpsc::Sender; use tokio::sync::oneshot; use tracing::error; -use zbus::zvariant::Fd; +use zbus::zvariant::{self, Fd}; use zbus::{fdo, interface, Connection, SignalContext}; use crate::daemon::root::{Command, RootCommand}; @@ -135,14 +135,14 @@ impl SteamOSManager { } } - async fn update_bios(&mut self) -> fdo::Result { + async fn update_bios(&mut self) -> fdo::Result { // Update the bios as needed self.process_manager .get_command_object_path("/usr/bin/jupiter-biosupdate", &["--auto"], "updating BIOS") .await } - async fn update_dock(&mut self) -> fdo::Result { + async fn update_dock(&mut self) -> fdo::Result { // Update the dock firmware as needed self.process_manager .get_command_object_path( @@ -153,7 +153,7 @@ impl SteamOSManager { .await } - async fn trim_devices(&mut self) -> fdo::Result { + async fn trim_devices(&mut self) -> fdo::Result { // Run steamos-trim-devices script self.process_manager .get_command_object_path( @@ -169,7 +169,7 @@ impl SteamOSManager { device: &str, label: &str, validate: bool, - ) -> fdo::Result { + ) -> fdo::Result { let mut args = vec!["--label", label, "--device", device]; if !validate { args.push("--skip-validation"); diff --git a/src/manager/user.rs b/src/manager/user.rs index 008ccc1..ceb05d7 100644 --- a/src/manager/user.rs +++ b/src/manager/user.rs @@ -11,8 +11,8 @@ use std::collections::HashMap; use tokio::sync::mpsc::Sender; use tracing::error; use zbus::proxy::Builder; -use zbus::zvariant::Fd; -use zbus::{fdo, interface, Connection, Proxy, SignalContext}; +use zbus::zvariant::{self, Fd}; +use zbus::{fdo, interface, CacheProperties, Connection, Proxy, SignalContext}; use crate::cec::{HdmiCecControl, HdmiCecState}; use crate::daemon::user::Command; @@ -79,7 +79,7 @@ impl SteamOSManager { .destination("com.steampowered.SteamOSManager1")? .path("/com/steampowered/SteamOSManager1")? .interface("com.steampowered.SteamOSManager1.RootManager")? - .cache_properties(zbus::CacheProperties::No) + .cache_properties(CacheProperties::No) .build() .await?, channel, @@ -170,15 +170,15 @@ impl SteamOSManager { } } - async fn update_bios(&self) -> fdo::Result { + async fn update_bios(&self) -> fdo::Result { method!(self, "UpdateBios") } - async fn update_dock(&self) -> fdo::Result { + async fn update_dock(&self) -> fdo::Result { method!(self, "UpdateDock") } - async fn trim_devices(&self) -> fdo::Result { + async fn trim_devices(&self) -> fdo::Result { method!(self, "TrimDevices") } @@ -187,7 +187,7 @@ impl SteamOSManager { device: &str, label: &str, validate: bool, - ) -> fdo::Result { + ) -> fdo::Result { method!(self, "FormatDevice", device, label, validate) } diff --git a/src/process.rs b/src/process.rs index 70b85a7..16c9166 100644 --- a/src/process.rs +++ b/src/process.rs @@ -15,7 +15,7 @@ use std::os::unix::process::ExitStatusExt; use std::process::ExitStatus; use tokio::process::{Child, Command}; use tracing::error; -use zbus::{fdo, interface}; +use zbus::{fdo, interface, zvariant, Connection}; use crate::error::to_zbus_fdo_error; @@ -25,7 +25,7 @@ pub struct ProcessManager { // The thing that manages subprocesses. // Keeps a handle to the zbus connection and // what the next process id on the bus should be - connection: zbus::Connection, + connection: Connection, next_process: u32, } @@ -36,7 +36,7 @@ pub struct Job { } impl ProcessManager { - pub fn new(conn: zbus::Connection) -> ProcessManager { + pub fn new(conn: Connection) -> ProcessManager { ProcessManager { connection: conn, next_process: 0, @@ -48,7 +48,7 @@ impl ProcessManager { executable: &str, args: &[impl AsRef], operation_name: &str, - ) -> fdo::Result { + ) -> fdo::Result { // Run the given executable and give back an object path let path = format!("{}{}", PROCESS_PREFIX, self.next_process); self.next_process += 1; @@ -60,7 +60,7 @@ impl ProcessManager { .object_server() .at(path.as_str(), pm) .await?; - zbus::zvariant::OwnedObjectPath::try_from(path).map_err(to_zbus_fdo_error) + zvariant::OwnedObjectPath::try_from(path).map_err(to_zbus_fdo_error) } pub async fn run_long_command(executable: &str, args: &[impl AsRef]) -> Result { diff --git a/src/sls/ftrace.rs b/src/sls/ftrace.rs index 629ee5f..3253384 100644 --- a/src/sls/ftrace.rs +++ b/src/sls/ftrace.rs @@ -7,8 +7,7 @@ use tokio::fs; use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::net::unix::pipe; use tracing::{error, info}; -use zbus::connection::Connection; -use zbus::zvariant; +use zbus::{zvariant, Connection}; use crate::{get_appid, path, read_comm, Service}; diff --git a/src/systemd.rs b/src/systemd.rs index 1249b16..baca43d 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -9,7 +9,7 @@ use anyhow::{anyhow, bail, Result}; use std::path::PathBuf; use zbus::zvariant::OwnedObjectPath; -use zbus::Connection; +use zbus::{CacheProperties, Connection}; #[zbus::proxy( interface = "org.freedesktop.systemd1.Unit", @@ -88,7 +88,7 @@ impl<'dbus> SystemdUnit<'dbus> { let path = String::from(path.to_str().ok_or(anyhow!("Unit name {name} invalid"))?); Ok(SystemdUnit { proxy: SystemdUnitProxy::builder(&connection) - .cache_properties(zbus::CacheProperties::No) + .cache_properties(CacheProperties::No) .path(path)? .build() .await?,