AsyncTask

Struct AsyncTask 

Source
pub struct AsyncTask<T: ConditionalSend> { /* private fields */ }
Expand description

A wrapper type around an async future. The future may be executed asynchronously by an TaskRunner or TaskPool bevy system parameter.

Implementations§

Source§

impl AsyncTask<()>

Source

pub async fn sleep(duration: Duration) -> Self

A task which sleeps for a specified duration.

Source§

impl<T> AsyncTask<T>
where T: ConditionalSend + 'static,

Source

pub fn new<F>(fut: F) -> Self
where F: ConditionalSendFuture<Output = T> + 'static, F::Output: ConditionalSend + 'static,

Create an async task from a future.

Source

pub fn pending() -> Self

Never resolves to a value or becomes ready.

Source

pub fn split(self) -> (Pin<Box<impl Future<Output = ()>>>, AsyncReceiver<T>)

Split the task into a runnable future and receiver. This is a low-level operation and only useful for specific needs.

Source

pub fn with_timeout(self, dur: Duration) -> TimedAsyncTask<T>

Add a timeout for this task.

Trait Implementations§

Source§

impl<T> Debug for AsyncTask<T>
where T: Debug + Send,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, Fnc> From<Fnc> for AsyncTask<T>
where Fnc: ConditionalSendFuture<Output = T> + 'static, Fnc::Output: ConditionalSend + 'static,

Source§

fn from(value: Fnc) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for AsyncTask<T>

§

impl<T> !RefUnwindSafe for AsyncTask<T>

§

impl<T> Send for AsyncTask<T>

§

impl<T> !Sync for AsyncTask<T>

§

impl<T> Unpin for AsyncTask<T>

§

impl<T> !UnwindSafe for AsyncTask<T>

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> CompatExt for T

Source§

fn compat(self) -> Compat<T>

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. 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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
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.
Source§

impl<T> ConditionalSend for T
where T: Send,