pub struct BackgroundTask { /* private fields */ }Expand description
A BackgroundTask does not actually execute any code, only act as a handler, primarily to query
the status of the task, and to cancel the task.
If you are looking to execute code in the background, consider using rusts threading API, or if you
want the core to execute the task on a worker thread, instead use the crate::worker_thread API.
NOTE: If you do not call BackgroundTask::finish or BackgroundTask::cancel, the task will
persist even after it has been dropped, use OwnedBackgroundTaskGuard to ensure the task is
finished, see BackgroundTask::enter for usage.
Implementations§
Source§impl BackgroundTask
impl BackgroundTask
Sourcepub fn new(initial_text: &str, can_cancel: bool) -> Ref<Self>
pub fn new(initial_text: &str, can_cancel: bool) -> Ref<Self>
Begin the BackgroundTask, you must manually finish the task by calling BackgroundTask::finish.
If you wish to automatically finish the task when leaving the scope, use BackgroundTask::enter.
Sourcepub fn enter(&self) -> OwnedBackgroundTaskGuard
pub fn enter(&self) -> OwnedBackgroundTaskGuard
Creates a OwnedBackgroundTaskGuard that is responsible for finishing the background task
once dropped. Because the status of a task does not dictate the underlying objects’ lifetime,
this can be safely done without requiring exclusive ownership.
pub fn can_cancel(&self) -> bool
pub fn is_cancelled(&self) -> bool
pub fn cancel(&self)
pub fn is_finished(&self) -> bool
pub fn finish(&self)
pub fn progress_text(&self) -> String
pub fn set_progress_text(&self, text: &str)
pub fn running_tasks() -> Array<BackgroundTask>
Trait Implementations§
Source§impl CoreArrayProvider for BackgroundTask
impl CoreArrayProvider for BackgroundTask
Source§impl Debug for BackgroundTask
impl Debug for BackgroundTask
Source§impl Hash for BackgroundTask
impl Hash for BackgroundTask
Source§impl PartialEq for BackgroundTask
impl PartialEq for BackgroundTask
Source§impl ToOwned for BackgroundTask
impl ToOwned for BackgroundTask
Source§type Owned = Ref<BackgroundTask>
type Owned = Ref<BackgroundTask>
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
impl Eq for BackgroundTask
impl Send for BackgroundTask
impl StructuralPartialEq for BackgroundTask
impl Sync for BackgroundTask
Auto Trait Implementations§
impl Freeze for BackgroundTask
impl RefUnwindSafe for BackgroundTask
impl Unpin for BackgroundTask
impl UnwindSafe for BackgroundTask
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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