pub struct Task { /* private fields */ }Expand description
First-class immutable task declaration owned by exactly one Phase.
Implementations§
Source§impl Task
impl Task
Sourcepub fn one_shot<W>(
id: impl Into<String>,
label: impl Into<String>,
workload: W,
) -> Self
pub fn one_shot<W>( id: impl Into<String>, label: impl Into<String>, workload: W, ) -> Self
Creates a one-shot task.
Sourcepub fn progress<W>(
id: impl Into<String>,
label: impl Into<String>,
workload: W,
) -> Self
pub fn progress<W>( id: impl Into<String>, label: impl Into<String>, workload: W, ) -> Self
Creates a task that may report progress through its context.
Sourcepub fn completed(id: impl Into<String>, label: impl Into<String>) -> Self
pub fn completed(id: impl Into<String>, label: impl Into<String>) -> Self
Creates an application-verified task that is already satisfied.
Sourcepub fn category(self, category: impl Into<String>) -> Self
pub fn category(self, category: impl Into<String>) -> Self
Sets the optional application-defined task category.
Sourcepub fn metadata(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn metadata(self, key: impl Into<String>, value: impl Into<Value>) -> Self
Adds application-defined metadata used for inspection and selection.
Sourcepub fn category_name(&self) -> &str
pub fn category_name(&self) -> &str
Returns the application-defined task category.
Sourcepub const fn mode(&self) -> TaskMode
pub const fn mode(&self) -> TaskMode
Returns whether the task reports iterative progress or one-shot status.
Sourcepub fn metadata_value(&self, key: &str) -> Option<&Value>
pub fn metadata_value(&self, key: &str) -> Option<&Value>
Borrows one application-defined metadata value.
Sourcepub fn require_value(&self, key: &str) -> Result<&Value, StudyError>
pub fn require_value(&self, key: &str) -> Result<&Value, StudyError>
Borrows one required task parameter.
Sourcepub fn decode_value<T>(&self, key: &str) -> Result<T, StudyError>where
T: DeserializeOwned,
pub fn decode_value<T>(&self, key: &str) -> Result<T, StudyError>where
T: DeserializeOwned,
Decodes one required task parameter without first cloning its JSON tree.
Sourcepub fn metadata_iter(&self) -> impl Iterator<Item = (&str, &Value)> + '_
pub fn metadata_iter(&self) -> impl Iterator<Item = (&str, &Value)> + '_
Iterates application-defined metadata.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Task
impl !Sync for Task
impl !UnwindSafe for Task
impl Freeze for Task
impl Send for Task
impl Unpin for Task
impl UnsafeUnpin 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> 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 more