Skip to main content

EventWriter

Struct EventWriter 

Source
pub struct EventWriter<'w, T: Send + 'static> { /* private fields */ }
Expand description

Exclusive write access to the Events<T> resource.

Use this in a system to send events that other systems can read on the next schedule tick via EventReader<T>.

ⓘ
fn fire_cannon(mut writer: EventWriter<'_, CannonFired>) {
    writer.send(CannonFired { power: 9000 });
}

Implementations§

Source§

impl<'w, T: Send + 'static> EventWriter<'w, T>

Source

pub fn send(&mut self, event: T)

Send an event. Readable by EventReader<T> systems on the next tick.

Trait Implementations§

Source§

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

Source§

type Item<'w> = EventWriter<'w, T>

The concrete type produced for a given world lifetime.
Source§

fn access() -> Vec<Access>

Declare what world data this parameter accesses.
Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Extract the parameter from the world. Read more

Auto Trait Implementations§

§

impl<'w, T> !UnwindSafe for EventWriter<'w, T>

§

impl<'w, T> Freeze for EventWriter<'w, T>
where &'w mut Events<T>: Freeze,

§

impl<'w, T> RefUnwindSafe for EventWriter<'w, T>
where &'w mut Events<T>: RefUnwindSafe,

§

impl<'w, T> Send for EventWriter<'w, T>
where &'w mut Events<T>: Send,

§

impl<'w, T> Sync for EventWriter<'w, T>
where &'w mut Events<T>: Sync,

§

impl<'w, T> Unpin for EventWriter<'w, T>
where &'w mut Events<T>: Unpin,

§

impl<'w, T> UnsafeUnpin for EventWriter<'w, T>
where &'w mut Events<T>: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.