TaskStream

Struct TaskStream 

Source
pub struct TaskStream<'s, T>(/* private fields */);
Expand description

A Bevy SystemParam to execute async streams in the background.

Implementations§

Source§

impl<T> TaskStream<'_, T>
where T: ConditionalSend + 'static,

Source

pub fn is_idle(&self) -> bool

Returns whether the stream is idle (not started).

Source

pub fn is_pending(&self) -> bool

Returns whether the stream is pending (running, but not finished).

Source

pub fn is_finished(&self) -> bool

Returns whether the stream is finished.

Source

pub fn start(&mut self, stream: impl Into<AsyncStream<T>>)

Start an async stream in the background. If there is an existing stream pending, it will be dropped and replaced with the given stream.

Source

pub fn forget(&mut self)

Forget the stream being run. This does not stop the stream.

Note: Bevy does not support cancelling a task on web currently.

Source

pub fn poll_next(&mut self) -> Poll<Option<T>>

Poll for the next item. Returns Poll::Ready(Some(T)) if an item is available, Poll::Ready(None) if the stream is finished, or Poll::Pending if waiting.

Trait Implementations§

Source§

impl<'s, T: Debug> Debug for TaskStream<'s, T>

Source§

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

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

impl<T: Send + 'static> ExclusiveSystemParam for TaskStream<'_, T>

Source§

type State = SyncCell<Option<AsyncStreamReceiver<T>>>

Used to store data which persists across invocations of a system.
Source§

type Item<'s> = TaskStream<'s, T>

The item type returned when constructing this system param. See SystemParam::Item.
Source§

fn init(_world: &mut World, _system_meta: &mut SystemMeta) -> Self::State

Creates a new instance of this param’s State.
Source§

fn get_param<'s>( state: &'s mut Self::State, _system_meta: &SystemMeta, ) -> Self::Item<'s>

Creates a parameter to be passed into an ExclusiveSystemParamFunction.
Source§

impl<T: Send + 'static> SystemParam for TaskStream<'_, T>

Source§

type State = SyncCell<Option<AsyncStreamReceiver<T>>>

Used to store data which persists across invocations of a system.
Source§

type Item<'w, 's> = TaskStream<'s, T>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
Source§

fn init_state(_world: &mut World) -> Self::State

Creates a new instance of this param’s State.
Source§

unsafe fn get_param<'w, 's>( state: &'s mut Self::State, _system_meta: &SystemMeta, _world: UnsafeWorldCell<'w>, _change_tick: Tick, ) -> Self::Item<'w, 's>

Creates a parameter to be passed into a SystemParamFunction. Read more
Source§

fn init_access( _state: &Self::State, _system_meta: &mut SystemMeta, _component_access_set: &mut FilteredAccessSet, _world: &mut World, )

Registers any World access used by this SystemParam
Source§

fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during ApplyDeferred.
Source§

fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )

Queues any deferred mutations to be applied at the next ApplyDeferred.
Source§

unsafe fn validate_param( state: &mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'_>, ) -> Result<(), SystemParamValidationError>

Validates that the param can be acquired by the get_param. Read more
Source§

impl<T: Send + 'static> ReadOnlySystemParam for TaskStream<'_, T>

Auto Trait Implementations§

§

impl<'s, T> Freeze for TaskStream<'s, T>

§

impl<'s, T> !RefUnwindSafe for TaskStream<'s, T>

§

impl<'s, T> Send for TaskStream<'s, T>
where T: Send,

§

impl<'s, T> Sync for TaskStream<'s, T>
where T: Send,

§

impl<'s, T> Unpin for TaskStream<'s, T>

§

impl<'s, T> !UnwindSafe for TaskStream<'s, 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,