pub struct AsyncJob<T = AnyCallback> { /* private fields */ }Expand description
An awaitable JobID. AsyncJob is untyped, AsyncJob<T> typed.
Implementations§
Source§impl<T> AsyncJob<T>
impl<T> AsyncJob<T>
Sourcepub fn new(job_id: JobID) -> AsyncJob<T>
pub fn new(job_id: JobID) -> AsyncJob<T>
Creates a job. Register it with the job manager by handing over its
sender (AsyncJob::take_sender).
Sourcepub fn timeout(&self) -> Duration
pub fn timeout(&self) -> Duration
How long until this job times out and is cancelled. 10 seconds by default.
Sourcepub fn set_timeout(&mut self, timeout: Duration)
pub fn set_timeout(&mut self, timeout: Duration)
Sets how long until this job times out and is cancelled.
Sourcepub fn is_timedout(&self) -> bool
pub fn is_timedout(&self) -> bool
Whether this job has timed out.
Sourcepub fn add_result(&mut self, callback: Box<dyn CallbackMsg>) -> bool
pub fn add_result(&mut self, callback: Box<dyn CallbackMsg>) -> bool
Adds a callback to the job’s results. For the untyped job, one callback always completes it.
Sourcepub fn set_failed(&mut self, due_to_remote_failure: bool)
pub fn set_failed(&mut self, due_to_remote_failure: bool)
Fails the job: due_to_remote_failure if Steam reported a failure,
otherwise it timed out.
Sourcepub fn take_sender(
&mut self,
) -> Option<Sender<Result<Box<dyn CallbackMsg>, SteamError>>>
pub fn take_sender( &mut self, ) -> Option<Sender<Result<Box<dyn CallbackMsg>, SteamError>>>
Hands the sending half of the completion channel to the job manager, which completes the job when the matching callback arrives.
Sourcepub fn into_receiver(self) -> JobReceiver
pub fn into_receiver(self) -> JobReceiver
Takes the receiving half of the completion channel.
Source§impl<T: CallbackMsg> AsyncJob<T>
impl<T: CallbackMsg> AsyncJob<T>
Sourcepub fn to_task(self) -> TypedJobReceiver<T>
pub fn to_task(self) -> TypedJobReceiver<T>
Converts this job into its awaitable form.
Sourcepub async fn wait(self) -> Result<T, SteamError>
pub async fn wait(self) -> Result<T, SteamError>
Waits for the job’s result.
Trait Implementations§
Auto Trait Implementations§
impl<T = AnyCallback> !RefUnwindSafe for AsyncJob<T>
impl<T = AnyCallback> !UnwindSafe for AsyncJob<T>
impl<T> Freeze for AsyncJob<T>
impl<T> Send for AsyncJob<T>
impl<T> Sync for AsyncJob<T>
impl<T> Unpin for AsyncJob<T>
impl<T> UnsafeUnpin for AsyncJob<T>
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