Skip to main content

InMemoryTaskRegistry

Struct InMemoryTaskRegistry 

Source
pub struct InMemoryTaskRegistry { /* private fields */ }
Expand description

In-memory task registry backed by HashMap + Mutex.

Thread-safe via interior mutability. All tasks and dependencies are stored in memory — lost on drop.

§Example

use pe_tasks::InMemoryTaskRegistry;

let registry = InMemoryTaskRegistry::new();

Implementations§

Source§

impl InMemoryTaskRegistry

Source

pub fn new() -> Self

Create with default lifecycle (transition validation only).

Source

pub fn with_lifecycle(lifecycle: impl TaskLifecycle + 'static) -> Self

Create with a custom lifecycle.

Trait Implementations§

Source§

impl Default for InMemoryTaskRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TaskRegistry for InMemoryTaskRegistry

Source§

fn create<'life0, 'async_trait>( &'life0 self, task: Task, ) -> Pin<Box<dyn Future<Output = Result<Task, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new task. Returns the created task with generated ID.
Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<Task>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a task by ID. Returns None if not found or deleted.
Source§

fn update<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 Task, ) -> Pin<Box<dyn Future<Output = Result<Task, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update an existing task. Returns the updated task.
Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<bool, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Soft-delete a task (sets deleted_at). Returns true if found.
Source§

fn restore<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<bool, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Restore a soft-deleted task. Returns true if found in trash.
Source§

fn update_status<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, status: TaskStatus, result: Option<Value>, error: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Task, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update task status (with lifecycle validation).
Source§

fn list<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 TaskFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List tasks matching a filter.
Source§

fn get_subtasks<'life0, 'life1, 'async_trait>( &'life0 self, parent_id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get direct subtasks of a parent.
Source§

fn get_tree<'life0, 'life1, 'async_trait>( &'life0 self, root_id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the full subtask tree (recursive) rooted at a task.
Source§

fn add_dependency<'life0, 'async_trait>( &'life0 self, dep: TaskDependency, ) -> Pin<Box<dyn Future<Output = Result<(), PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a dependency edge. Rejects if it would create a cycle.
Source§

fn remove_dependency<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, task_id: &'life1 TaskId, depends_on_id: &'life2 TaskId, ) -> Pin<Box<dyn Future<Output = Result<(), PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove a dependency edge.
Source§

fn get_dependencies<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Vec<TaskDependency>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all dependencies of a task (what it depends on).
Source§

fn get_dependents<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Vec<TaskDependency>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all dependents of a task (what depends on it).
Source§

fn get_ready_tasks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all tasks that are ready to execute (no incomplete Blocks deps).

Auto Trait Implementations§

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.