Expand description
Tokio-based command execution implementation for reqsign.
This crate provides TokioCommandExecute
, an async command executor that implements
the CommandExecute
trait from reqsign_core
using Tokio’s process operations.
§Overview
TokioCommandExecute
enables reqsign to execute external commands asynchronously using
Tokio’s process spawning capabilities. This is particularly useful when retrieving
credentials from external programs or CLI tools.
§Example
ⓘ
use reqsign_core::Context;
use reqsign_command_execute_tokio::TokioCommandExecute;
use reqsign_file_read_tokio::TokioFileRead;
use reqsign_http_send_reqwest::ReqwestHttpSend;
#[tokio::main]
async fn main() {
// Create a context with Tokio command executor
let ctx = Context::new()
.with_file_read(TokioFileRead::default())
.with_http_send(ReqwestHttpSend::default())
.with_command_execute(TokioCommandExecute::default())
.unwrap();
// The context can now execute commands asynchronously
match ctx.command_execute("echo", &["hello", "world"]).await {
Ok(output) => {
if output.success() {
println!("Output: {}", String::from_utf8_lossy(&output.stdout));
}
}
Err(e) => eprintln!("Failed to execute command: {}", e),
}
}
§Usage with Service Signers
ⓘ
use reqsign_core::{Context, Signer};
use reqsign_command_execute_tokio::TokioCommandExecute;
use reqsign_file_read_tokio::TokioFileRead;
use reqsign_http_send_reqwest::ReqwestHttpSend;
// Cloud services that use external credential processes need command execution
let ctx = Context::new()
.with_file_read(TokioFileRead::default())
.with_http_send(ReqwestHttpSend::default())
.with_command_execute(TokioCommandExecute::default())
?;
// Create a signer that can execute credential helper processes
// let signer = Signer::new(ctx, credential_loader, request_builder);
Structs§
- Tokio
Command Execute - Tokio-based implementation of the
CommandExecute
trait.