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>,
}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
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 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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TaskConfig
impl Debug for TaskConfig
Source§impl Default for TaskConfig
impl Default for TaskConfig
Source§impl<'de> Deserialize<'de> for TaskConfig
impl<'de> Deserialize<'de> for TaskConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TaskConfig
impl RefUnwindSafe for TaskConfig
impl Send for TaskConfig
impl Sync for TaskConfig
impl Unpin for TaskConfig
impl UnwindSafe for TaskConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more