mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 01:12:30 -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;
|
use tokio::process::Command;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub async fn script_exit_code<P: AsRef<OsStr>>(
|
pub async fn script_exit_code(
|
||||||
executable: P,
|
executable: impl AsRef<OsStr>,
|
||||||
args: &[impl AsRef<OsStr>],
|
args: &[impl AsRef<OsStr>],
|
||||||
) -> Result<i32> {
|
) -> Result<i32> {
|
||||||
// Run given script and return the exit code
|
// Run given script and return the exit code
|
||||||
|
@ -28,17 +28,14 @@ pub async fn script_exit_code<P: AsRef<OsStr>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub async fn script_exit_code<P: AsRef<OsStr>>(
|
pub async fn script_exit_code(executable: AsRef<OsStr>, args: &[impl AsRef<OsStr>]) -> Result<i32> {
|
||||||
executable: P,
|
|
||||||
args: &[impl AsRef<OsStr>],
|
|
||||||
) -> Result<i32> {
|
|
||||||
let test = crate::testing::current();
|
let test = crate::testing::current();
|
||||||
let args: Vec<&OsStr> = args.iter().map(|arg| arg.as_ref()).collect();
|
let args: Vec<&OsStr> = args.iter().map(|arg| arg.as_ref()).collect();
|
||||||
let cb = test.process_cb.get();
|
let cb = test.process_cb.get();
|
||||||
cb(executable.as_ref(), args.as_ref()).map(|(res, _)| res)
|
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.
|
// Run given script to get exit code and return true on success.
|
||||||
// Return Err on failure, but also print an error if needed
|
// Return Err on failure, but also print an error if needed
|
||||||
match script_exit_code(executable, args).await {
|
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))]
|
#[cfg(not(test))]
|
||||||
pub async fn script_output<P: AsRef<OsStr>>(
|
pub async fn script_output(
|
||||||
executable: P,
|
executable: impl AsRef<OsStr>,
|
||||||
args: &[impl AsRef<OsStr>],
|
args: &[impl AsRef<OsStr>],
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
// Run given command and return the output given
|
// Run given command and return the output given
|
||||||
|
@ -63,8 +60,8 @@ pub async fn script_output<P: AsRef<OsStr>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub async fn script_output<P: AsRef<OsStr>>(
|
pub async fn script_output(
|
||||||
executable: P,
|
executable: impl AsRef<OsStr>,
|
||||||
args: &[impl AsRef<OsStr>],
|
args: &[impl AsRef<OsStr>],
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let test = crate::testing::current();
|
let test = crate::testing::current();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue