pub struct State {
    pub settings: Settings,
    pub tasks: BTreeMap<usize, Task>,
    pub groups: BTreeMap<String, Group>,
    pub config_path: Option<PathBuf>,
}
Expand description

This is the full representation of the current state of the Pueue daemon.

This includes

  • The currently used settings.
  • The full task list
  • The current status of all tasks
  • All known groups.

However, the State does NOT include:

  • Information about child processes
  • Handles to child processes

That information is saved in the daemon’s TaskHandler.

Most functions implemented on the state shouldn’t be used by third party software. The daemon is constantly changing and persisting the state.
Any changes applied to a state and saved to disk, will most likely be overwritten after a short time.

The daemon uses the state as a piece of shared memory between it’s threads. It’s wrapped in a MutexGuard, which allows us to guarantee sequential access to any crucial information, such as status changes and incoming commands by the client.

Fields

settings: Settings

The current settings used by the daemon.

tasks: BTreeMap<usize, Task>

All tasks currently managed by the daemon.

groups: BTreeMap<String, Group>

All groups with their current state a configuration.

config_path: Option<PathBuf>

Used to store an configuration path that has been explicitely specified. Without this, the default config path will be used instead.

Implementations

Create a new default state.

Add a new task

A small helper to change the status of a specific task.

Add a new group to the daemon.
This also check if the given group already exists. Create a state.group entry and a settings.group entry, if it doesn’t.

Remove a group. This also iterates through all tasks and sets any tasks’ group to the default group if it matches the deleted group.

Set the group status (running/paused) for all groups including the default queue.

Get all ids of task inside a specific group.

This checks, whether some tasks match the expected filter criteria.
The first result is the list of task_ids that match these statuses.
The second result is the list of task_ids that don’t match these statuses.

By default, this checks all tasks in the current state. If a list of task_ids is provided as the third parameter, only those tasks will be checked.

Same as [tasks_in_statuses], but only checks for tasks of a specific group.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.