pub struct State {
pub tasks: BTreeMap<usize, Task>,
pub groups: BTreeMap<String, Group>,
}
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§
§tasks: BTreeMap<usize, Task>
All tasks currently managed by the daemon.
groups: BTreeMap<String, Group>
All groups with their current state a configuration.
Implementations§
source§impl State
impl State
sourcepub fn change_status(&mut self, id: usize, new_status: TaskStatus)
pub fn change_status(&mut self, id: usize, new_status: TaskStatus)
A small helper to change the status of a specific task.
sourcepub fn create_group(&mut self, name: &str) -> &mut Group
pub fn create_group(&mut self, name: &str) -> &mut Group
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.
sourcepub fn remove_group(&mut self, group: &str) -> Result<(), Error>
pub fn remove_group(&mut self, group: &str) -> Result<(), Error>
Remove a group.
This also iterates through all tasks and sets any tasks’ group
to the default
group if it matches the deleted group.
sourcepub fn set_status_for_all_groups(&mut self, status: GroupStatus)
pub fn set_status_for_all_groups(&mut self, status: GroupStatus)
Set the group status (running/paused) for all groups including the default queue.
sourcepub fn task_ids_in_group(&self, group: &str) -> Vec<usize>
pub fn task_ids_in_group(&self, group: &str) -> Vec<usize>
Get all ids of task inside a specific group.
sourcepub fn filter_tasks<F>(
&self,
condition: F,
task_ids: Option<Vec<usize>>
) -> FilteredTasks
pub fn filter_tasks<F>( &self, condition: F, task_ids: Option<Vec<usize>> ) -> FilteredTasks
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.
sourcepub fn filter_tasks_of_group<F>(
&self,
condition: F,
group: &str
) -> FilteredTasks
pub fn filter_tasks_of_group<F>( &self, condition: F, group: &str ) -> FilteredTasks
Same as State::filter_tasks, but only checks for tasks of a specific group.
Trait Implementations§
source§impl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
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>,
source§impl PartialEq for State
impl PartialEq for State
impl Eq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.