pub struct Task {
pub id: Uuid,
pub document_box: String,
pub status: TaskStatus,
pub output_data: Option<Value>,
pub created_at: DateTime<Utc>,
pub completed_at: Option<DateTime<Utc>>,
}Expand description
Represents a stored asynchronous task progress
Fields§
§id: UuidUnique ID of the task
document_box: StringID of the document box the task belongs to
status: TaskStatusStatus of the task
output_data: Option<Value>Output data from the task completion
created_at: DateTime<Utc>When the task was created
completed_at: Option<DateTime<Utc>>Implementations§
Source§impl Task
impl Task
Sourcepub async fn create(
db: impl PgExecutor<'_>,
document_box: String,
) -> Result<Task, Error>
pub async fn create( db: impl PgExecutor<'_>, document_box: String, ) -> Result<Task, Error>
Stores / updates the stored user data, returns back the user ID
pub async fn find( db: impl PgExecutor<'_>, id: Uuid, document_box: &str, ) -> Result<Option<Task>, Error>
Sourcepub async fn complete_task(
&mut self,
db: impl PgExecutor<'_>,
status: TaskStatus,
output_data: Option<Value>,
) -> Result<(), Error>
pub async fn complete_task( &mut self, db: impl PgExecutor<'_>, status: TaskStatus, output_data: Option<Value>, ) -> Result<(), Error>
Mark the task as completed and set its output data
Sourcepub async fn delete_expired(
db: impl PgExecutor<'_>,
before: DateTime<Utc>,
) -> Result<PgQueryResult, Error>
pub async fn delete_expired( db: impl PgExecutor<'_>, before: DateTime<Utc>, ) -> Result<PgQueryResult, Error>
Deletes all tasks where the creation date is older than the before date
Trait Implementations§
Source§impl<'a, R> FromRow<'a, R> for Taskwhere
R: Row,
&'a str: ColumnIndex<R>,
Uuid: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
String: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
TaskStatus: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<Value>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
DateTime<Utc>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<DateTime<Utc>>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
impl<'a, R> FromRow<'a, R> for Taskwhere
R: Row,
&'a str: ColumnIndex<R>,
Uuid: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
String: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
TaskStatus: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<Value>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
DateTime<Utc>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<DateTime<Utc>>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Source§impl Serialize for Task
impl Serialize for Task
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Task
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnwindSafe for Task
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.