Struct pueue_lib::state::State [−][src]
pub struct State {
pub settings: Settings,
pub tasks: BTreeMap<usize, Task>,
pub groups: BTreeMap<String, GroupStatus>,
// some fields omitted
}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, GroupStatus>All groups
Implementations
impl State[src]
impl State[src]pub fn new(settings: &Settings, config_path: Option<PathBuf>) -> State[src]
pub fn new(settings: &Settings, config_path: Option<PathBuf>) -> State[src]Create a new default state.
pub fn change_status(&mut self, id: usize, new_status: TaskStatus)[src]
pub fn change_status(&mut self, id: usize, new_status: TaskStatus)[src]A small helper to change the status of a specific task.
pub fn set_enqueue_at(&mut self, id: usize, enqueue_at: Option<DateTime<Local>>)[src]
pub fn set_enqueue_at(&mut self, id: usize, enqueue_at: Option<DateTime<Local>>)[src]Set the time a specific task should be enqueued at.
pub fn create_group(&mut self, group: &str)[src]
pub fn create_group(&mut self, group: &str)[src]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.
pub fn remove_group(&mut self, group: &str) -> Result<(), Error>[src]
pub fn remove_group(&mut self, group: &str) -> Result<(), Error>[src]Remove a group.
This also iterates through all tasks and sets any tasks’ group
to the default group if it matches the deleted group.
pub fn set_status_for_all_groups(&mut self, status: GroupStatus)[src]
pub fn set_status_for_all_groups(&mut self, status: GroupStatus)[src]Set the group status (running/paused) for all groups including the default queue.
pub fn task_ids_in_group_with_stati(
&self,
group: &str,
stati: Vec<TaskStatus>
) -> Vec<usize>[src]
pub fn task_ids_in_group_with_stati(
&self,
group: &str,
stati: Vec<TaskStatus>
) -> Vec<usize>[src]Get all ids of task with a specific state inside a specific group.
pub fn task_ids_in_group(&self, group: &str) -> Vec<usize>[src]
pub fn task_ids_in_group(&self, group: &str) -> Vec<usize>[src]Get all ids of task inside a specific group.
pub fn tasks_in_statuses(
&self,
statuses: Vec<TaskStatus>,
task_ids: Option<Vec<usize>>
) -> (Vec<usize>, Vec<usize>)[src]
pub fn tasks_in_statuses(
&self,
statuses: Vec<TaskStatus>,
task_ids: Option<Vec<usize>>
) -> (Vec<usize>, Vec<usize>)[src]This checks, whether some tasks have one of the specified statuses.
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.
pub fn is_task_removable(&self, task_id: &usize, to_delete: &[usize]) -> bool[src]
pub fn is_task_removable(&self, task_id: &usize, to_delete: &[usize]) -> bool[src]Check if a task can be deleted.
We have to check all dependant tasks, that haven’t finished yet.
This is necessary to prevent deletion of tasks which are specified as a dependency.
to_delete A list of task ids, which should also be deleted.
This allows to remove dependency tasks as well as their dependants.
pub fn handle_task_failure(&mut self, group: String)[src]
pub fn handle_task_failure(&mut self, group: String)[src]A small helper for handling task failures.
Users can specify whether they want to pause the task’s group or the
whole daemon on a failed tasks. This function wraps that logic and decides if anything should be
paused depending on the current settings.
group should be the name of the failed task.
pub fn reset(&mut self) -> Result<(), Error>[src]
pub fn reset(&mut self) -> Result<(), Error>[src]Do a full reset of the state. This doesn’t reset any processes!
pub fn save_settings(&self) -> Result<(), Error>[src]
pub fn save_settings(&self) -> Result<(), Error>[src]A small convenience wrapper for saving the settings to a file.
Trait Implementations
impl<'de> Deserialize<'de> for State[src]
impl<'de> Deserialize<'de> for State[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>, pub fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,