Struct pueue_lib::task::Task

source ·
pub struct Task {
Show 15 fields pub id: usize, pub created_at: DateTime<Local>, pub enqueued_at: Option<DateTime<Local>>, pub original_command: String, pub command: String, pub path: PathBuf, pub envs: HashMap<String, String>, pub group: String, pub dependencies: Vec<usize>, pub priority: i32, pub label: Option<String>, pub status: TaskStatus, pub prev_status: TaskStatus, pub start: Option<DateTime<Local>>, pub end: Option<DateTime<Local>>,
}
Expand description

Representation of a task. start will be set the second the task starts processing. result, output and end won’t be initialized, until the task has finished.

Fields§

§id: usize§created_at: DateTime<Local>§enqueued_at: Option<DateTime<Local>>§original_command: String§command: String§path: PathBuf§envs: HashMap<String, String>§group: String§dependencies: Vec<usize>§priority: i32§label: Option<String>§status: TaskStatus§prev_status: TaskStatus

This field is only used when editing the path/command of a task. It’s necessary, since we enter the Locked state during editing. However, we have to go back to the previous state after we finished editing.

TODO: Refactor this into a TaskStatus::Locked{previous_status: TaskStatus}.

§start: Option<DateTime<Local>>§end: Option<DateTime<Local>>

Implementations§

source§

impl Task

source

pub fn new( original_command: String, path: PathBuf, envs: HashMap<String, String>, group: String, starting_status: TaskStatus, dependencies: Vec<usize>, priority: i32, label: Option<String> ) -> Task

source

pub fn from_task(task: &Task) -> Task

A convenience function used to duplicate a task.

source

pub fn is_running(&self) -> bool

Whether the task is having a running process managed by the TaskHandler

source

pub fn is_done(&self) -> bool

Whether the task’s process finished.

source

pub fn failed(&self) -> bool

Check if the task errored.
It either:

  1. Finished successfully
  2. Didn’t finish yet.
source

pub fn is_stashed(&self) -> bool

Convenience helper on whether a task is stashed

source

pub fn is_queued(&self) -> bool

Check whether a task is queued or might soon be enqueued.

source

pub fn set_default_group(&mut self)

Small convenience function to set the task’s group to the default group.

source

pub fn is_in_default_group(&self) -> bool

Trait Implementations§

source§

impl Clone for Task

source§

fn clone(&self) -> Task

Returns a copy 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 Task

We use a custom Debug implementation for Task, as the envs field just has too much info in it and makes the log output much too verbose.

Furthermore, there might be secrets in the environment, resulting in a possible leak if users copy-paste their log output for debugging.

source§

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

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

impl<'de> Deserialize<'de> for Task

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Task

source§

fn eq(&self, other: &Task) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Task

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Task

source§

impl StructuralPartialEq for Task

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnwindSafe for Task

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

§

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>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,