pub struct TaskConfig {
pub command: String,
pub args: Option<Vec<String>>,
pub working_dir: Option<String>,
pub env: Option<HashMap<String, String>>,
pub timeout_ms: Option<u64>,
pub enable_stdin: Option<bool>,
pub ready_indicator: Option<String>,
pub ready_indicator_source: Option<StreamSource>,
}Expand description
Configuration for a task to be executed
Fields§
§command: StringThe command or executable to run
args: Option<Vec<String>>Arguments to pass to the command
working_dir: Option<String>Working directory for the command
env: Option<HashMap<String, String>>Environment variables for the command
timeout_ms: Option<u64>Maximum allowed runtime in milliseconds
enable_stdin: Option<bool>Allow providing input to the task via stdin
ready_indicator: Option<String>Optional string to indicate the task is ready (for long-running processes like servers)
ready_indicator_source: Option<StreamSource>Source of the ready indicator string (stdout/stderr)
Implementations§
Source§impl TaskConfig
impl TaskConfig
Sourcepub fn new(command: impl Into<String>) -> Self
pub fn new(command: impl Into<String>) -> Self
Create a new task configuration with the given command
§Example
use tcrm_task::tasks::config::TaskConfig;
let config = TaskConfig::new("echo");Sourcepub fn working_dir(self, dir: impl Into<String>) -> Self
pub fn working_dir(self, dir: impl Into<String>) -> Self
Set the working directory for the command
Sourcepub fn timeout_ms(self, timeout: u64) -> Self
pub fn timeout_ms(self, timeout: u64) -> Self
Set the maximum allowed runtime in milliseconds
Sourcepub fn enable_stdin(self, b: bool) -> Self
pub fn enable_stdin(self, b: bool) -> Self
Enable or disable stdin for the task
Sourcepub fn ready_indicator(self, indicator: impl Into<String>) -> Self
pub fn ready_indicator(self, indicator: impl Into<String>) -> Self
Set the ready indicator for the task
Sourcepub fn ready_indicator_source(self, source: StreamSource) -> Self
pub fn ready_indicator_source(self, source: StreamSource) -> Self
Set the source of the ready indicator
Sourcepub fn validate(&self) -> Result<(), TaskError>
pub fn validate(&self) -> Result<(), TaskError>
Validate the configuration
Returns Ok(()) if valid, or TaskError::InvalidConfiguration describing the problem
§Examples
use tcrm_task::tasks::config::TaskConfig;
// Valid config
let config = TaskConfig::new("echo");
assert!(config.validate().is_ok());
// Invalid config (empty command)
let config = TaskConfig::new("");
assert!(config.validate().is_err());Trait Implementations§
Source§impl Clone for TaskConfig
impl Clone for TaskConfig
Source§fn clone(&self) -> TaskConfig
fn clone(&self) -> TaskConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more