Import a few more zbus things to reduce namespace line length

This commit is contained in:
Vicki Pfau 2024-06-26 19:38:12 -07:00
parent 7213ea5179
commit 450541b2bd
5 changed files with 20 additions and 21 deletions

View file

@ -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<zbus::zvariant::OwnedObjectPath> {
async fn update_bios(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
// 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<zbus::zvariant::OwnedObjectPath> {
async fn update_dock(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
// 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<zbus::zvariant::OwnedObjectPath> {
async fn trim_devices(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
// 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<zbus::zvariant::OwnedObjectPath> {
) -> fdo::Result<zvariant::OwnedObjectPath> {
let mut args = vec!["--label", label, "--device", device];
if !validate {
args.push("--skip-validation");

View file

@ -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<zbus::zvariant::OwnedObjectPath> {
async fn update_bios(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "UpdateBios")
}
async fn update_dock(&self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
async fn update_dock(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "UpdateDock")
}
async fn trim_devices(&self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
async fn trim_devices(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "TrimDevices")
}
@ -187,7 +187,7 @@ impl SteamOSManager {
device: &str,
label: &str,
validate: bool,
) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "FormatDevice", device, label, validate)
}

View file

@ -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<OsStr>],
operation_name: &str,
) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
) -> fdo::Result<zvariant::OwnedObjectPath> {
// 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<OsStr>]) -> Result<Job> {

View file

@ -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};

View file

@ -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?,