mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -04:00
process: Clean up P: AsRef<> into impl AsRef<> where applicable
This commit is contained in:
parent
cefba9704e
commit
bcab18c5fb
1 changed files with 8 additions and 11 deletions
|
@ -13,8 +13,8 @@ use std::process::Stdio;
|
|||
use tokio::process::Command;
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub async fn script_exit_code<P: AsRef<OsStr>>(
|
||||
executable: P,
|
||||
pub async fn script_exit_code(
|
||||
executable: impl AsRef<OsStr>,
|
||||
args: &[impl AsRef<OsStr>],
|
||||
) -> Result<i32> {
|
||||
// Run given script and return the exit code
|
||||
|
@ -28,17 +28,14 @@ pub async fn script_exit_code<P: AsRef<OsStr>>(
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub async fn script_exit_code<P: AsRef<OsStr>>(
|
||||
executable: P,
|
||||
args: &[impl AsRef<OsStr>],
|
||||
) -> Result<i32> {
|
||||
pub async fn script_exit_code(executable: AsRef<OsStr>, args: &[impl AsRef<OsStr>]) -> Result<i32> {
|
||||
let test = crate::testing::current();
|
||||
let args: Vec<&OsStr> = args.iter().map(|arg| arg.as_ref()).collect();
|
||||
let cb = test.process_cb.get();
|
||||
cb(executable.as_ref(), args.as_ref()).map(|(res, _)| res)
|
||||
}
|
||||
|
||||
pub async fn run_script<P: AsRef<OsStr>>(executable: P, args: &[impl AsRef<OsStr>]) -> Result<()> {
|
||||
pub async fn run_script(executable: impl AsRef<OsStr>, args: &[impl AsRef<OsStr>]) -> Result<()> {
|
||||
// Run given script to get exit code and return true on success.
|
||||
// Return Err on failure, but also print an error if needed
|
||||
match script_exit_code(executable, args).await {
|
||||
|
@ -49,8 +46,8 @@ pub async fn run_script<P: AsRef<OsStr>>(executable: P, args: &[impl AsRef<OsStr
|
|||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub async fn script_output<P: AsRef<OsStr>>(
|
||||
executable: P,
|
||||
pub async fn script_output(
|
||||
executable: impl AsRef<OsStr>,
|
||||
args: &[impl AsRef<OsStr>],
|
||||
) -> Result<String> {
|
||||
// Run given command and return the output given
|
||||
|
@ -63,8 +60,8 @@ pub async fn script_output<P: AsRef<OsStr>>(
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub async fn script_output<P: AsRef<OsStr>>(
|
||||
executable: P,
|
||||
pub async fn script_output(
|
||||
executable: impl AsRef<OsStr>,
|
||||
args: &[impl AsRef<OsStr>],
|
||||
) -> Result<String> {
|
||||
let test = crate::testing::current();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue