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: SettingsThe 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.
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.
Trait Implementations
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 RefUnwindSafe for State
impl UnwindSafe for State
Blanket Implementations
Mutably borrows from an owned value. Read more