TaskSpec

Struct TaskSpec 

Source
pub struct TaskSpec {
    pub config: TaskConfig,
    pub shell: Option<TaskShell>,
    pub dependencies: Option<Vec<String>>,
    pub terminate_after_dependents_finished: Option<bool>,
    pub ignore_dependencies_error: Option<bool>,
}
Expand description

Task specification with dependency management and execution configuration.

Wraps a TaskConfig with additional metadata for dependency management, shell selection, and execution behavior in a task graph.

§Default Values

  • config: Default-initialized TaskConfig
  • shell: Some(TaskShell::None)
  • dependencies: None
  • terminate_after_dependents_finished: Some(false)
  • ignore_dependencies_error: Some(false)

§Examples

§Simple Task

use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;

let task = TaskSpec::new(
    TaskConfig::new("echo").args(["Hello, World!"])
);

§Task with Dependencies

use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;

let build_task = TaskSpec::new(
    TaskConfig::new("cargo").args(["build", "--release"])
)
.dependencies(["test", "lint"])
.shell(TaskShell::Auto)
.terminate_after_dependents(true);

§Task with Custom Configuration

use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;

let server_task = TaskSpec::new(
    TaskConfig::new("node")
        .args(["server.js"])
        .working_dir("/app")
        .enable_stdin(true)
        .timeout_ms(0) // No timeout
)
.shell(TaskShell::Auto)
.ignore_dependencies_error(true);

Fields§

§config: TaskConfig

The underlying task configuration containing command, arguments, and execution options.

Default: TaskConfig::default()

§shell: Option<TaskShell>

Shell to use for task execution. None means direct execution without shell.

Default: Some(TaskShell::None)

§dependencies: Option<Vec<String>>

List of task names this task depends on. Must complete before this task starts.

Default: None

§terminate_after_dependents_finished: Option<bool>

Whether to terminate this task when all dependent tasks finish. Useful for long-running services that should stop when their dependents complete.

Default: Some(false)

§ignore_dependencies_error: Option<bool>

Whether to ignore errors from dependency tasks and continue execution anyway.

Default: Some(false)

Implementations§

Source§

impl TaskSpec

Source

pub fn new(config: TaskConfig) -> Self

Creates a new task specification from a task configuration.

§Arguments
  • config - The underlying task configuration
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;

let task = TaskSpec::new(
    TaskConfig::new("ls").args(["-la"])
);
Source

pub fn shell(self, shell: TaskShell) -> Self

Sets the shell for task execution.

§Arguments
  • shell - The shell type to use
§Examples
use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;

let task = TaskSpec::new(TaskConfig::new("echo").args(["test"]))
    .shell(TaskShell::Auto);
Source

pub fn dependencies<I, S>(self, dependencies: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Adds dependencies to this task.

Dependencies must complete successfully before this task can start.

§Arguments
  • dependencies - An iterator of task names this task depends on
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;

let task = TaskSpec::new(TaskConfig::new("cargo").args(["build"]))
    .dependencies(["test", "lint"]);
Source

pub fn terminate_after_dependents(self, terminate: bool) -> Self

Sets whether to terminate this task when its dependents complete.

Useful for long-running services that should stop when their dependents finish.

§Arguments
  • terminate - Whether to terminate after dependents complete
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;

// A database server that should stop when tests finish
let db_task = TaskSpec::new(TaskConfig::new("postgres").args(["-D", "/data"]))
    .terminate_after_dependents(true);
Source

pub fn ignore_dependencies_error(self, ignore: bool) -> Self

Sets whether to ignore errors from dependency tasks.

When true, this task will run even if its dependencies fail.

§Arguments
  • ignore - Whether to ignore dependency errors
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;

// Cleanup task that should run regardless of test results
let cleanup = TaskSpec::new(TaskConfig::new("rm").args(["-rf", "/tmp/test"]))
    .dependencies(["test"])
    .ignore_dependencies_error(true);

Trait Implementations§

Source§

impl Clone for TaskSpec

Source§

fn clone(&self) -> TaskSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TaskSpec

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.