pub struct Receiver<'a, E, Q = NullReceiverQuery>where
E: Event,
Q: ReceiverQuery + 'static,{
pub event: &'a <E as Event>::This<'a>,
pub query: <Q as ReceiverQuery>::Item<'a>,
}
Expand description
A HandlerParam
which listens for events of type E
.
For more information, see the relevant tutorial chapter.
§Examples
use evenio::prelude::*;
#[derive(GlobalEvent)]
struct E;
let mut world = World::new();
world.add_handler(|r: Receiver<E>| {
println!("got event of type E!");
});
Fields§
§event: &'a <E as Event>::This<'a>
A reference to the received event.
query: <Q as ReceiverQuery>::Item<'a>
The result of the query. This field is meaningless if E
is not a
TargetedEvent
.
Trait Implementations§
Source§impl<'a, E, Q> Clone for Receiver<'a, E, Q>where
E: Clone + Event,
Q: Clone + ReceiverQuery + 'static,
<E as Event>::This<'a>: Clone,
<Q as ReceiverQuery>::Item<'a>: Clone,
impl<'a, E, Q> Clone for Receiver<'a, E, Q>where
E: Clone + Event,
Q: Clone + ReceiverQuery + 'static,
<E as Event>::This<'a>: Clone,
<Q as ReceiverQuery>::Item<'a>: Clone,
Source§impl<E> HandlerParam for Receiver<'_, E>where
E: GlobalEvent,
impl<E> HandlerParam for Receiver<'_, E>where
E: GlobalEvent,
Source§type This<'a> = Receiver<'a, E>
type This<'a> = Receiver<'a, E>
The type produced by this handler param. This must be the type
of
Self
but with the lifetime of 'a
.Source§fn init(
world: &mut World,
config: &mut HandlerConfig,
) -> Result<<Receiver<'_, E> as HandlerParam>::State, InitError>
fn init( world: &mut World, config: &mut HandlerConfig, ) -> Result<<Receiver<'_, E> as HandlerParam>::State, InitError>
Source§unsafe fn get<'a>(
_state: &'a mut <Receiver<'_, E> as HandlerParam>::State,
_info: &'a HandlerInfo,
event_ptr: EventPtr<'a>,
_target_location: EntityLocation,
_world: UnsafeWorldCell<'a>,
) -> <Receiver<'_, E> as HandlerParam>::This<'a>
unsafe fn get<'a>( _state: &'a mut <Receiver<'_, E> as HandlerParam>::State, _info: &'a HandlerInfo, event_ptr: EventPtr<'a>, _target_location: EntityLocation, _world: UnsafeWorldCell<'a>, ) -> <Receiver<'_, E> as HandlerParam>::This<'a>
Obtains a new instance of the handler parameter. Read more
Source§fn refresh_archetype(
_state: &mut <Receiver<'_, E> as HandlerParam>::State,
_arch: &Archetype,
)
fn refresh_archetype( _state: &mut <Receiver<'_, E> as HandlerParam>::State, _arch: &Archetype, )
Refresh an archetype for this handler param. Called whenever
Handler::refresh_archetype
is called.Source§fn remove_archetype(
_state: &mut <Receiver<'_, E> as HandlerParam>::State,
_arch: &Archetype,
)
fn remove_archetype( _state: &mut <Receiver<'_, E> as HandlerParam>::State, _arch: &Archetype, )
Remove the given archetype for this handler param. Called whenever
Handler::remove_archetype
is called.Source§impl<E, Q> HandlerParam for Receiver<'_, E, Q>where
E: TargetedEvent,
Q: Query + 'static,
impl<E, Q> HandlerParam for Receiver<'_, E, Q>where
E: TargetedEvent,
Q: Query + 'static,
Source§type This<'a> = Receiver<'a, E, Q>
type This<'a> = Receiver<'a, E, Q>
The type produced by this handler param. This must be the type
of
Self
but with the lifetime of 'a
.Source§fn init(
world: &mut World,
config: &mut HandlerConfig,
) -> Result<<Receiver<'_, E, Q> as HandlerParam>::State, InitError>
fn init( world: &mut World, config: &mut HandlerConfig, ) -> Result<<Receiver<'_, E, Q> as HandlerParam>::State, InitError>
Source§unsafe fn get<'a>(
state: &'a mut <Receiver<'_, E, Q> as HandlerParam>::State,
_info: &'a HandlerInfo,
event_ptr: EventPtr<'a>,
target_location: EntityLocation,
_world: UnsafeWorldCell<'a>,
) -> <Receiver<'_, E, Q> as HandlerParam>::This<'a>
unsafe fn get<'a>( state: &'a mut <Receiver<'_, E, Q> as HandlerParam>::State, _info: &'a HandlerInfo, event_ptr: EventPtr<'a>, target_location: EntityLocation, _world: UnsafeWorldCell<'a>, ) -> <Receiver<'_, E, Q> as HandlerParam>::This<'a>
Obtains a new instance of the handler parameter. Read more
Source§fn refresh_archetype(
state: &mut <Receiver<'_, E, Q> as HandlerParam>::State,
arch: &Archetype,
)
fn refresh_archetype( state: &mut <Receiver<'_, E, Q> as HandlerParam>::State, arch: &Archetype, )
Refresh an archetype for this handler param. Called whenever
Handler::refresh_archetype
is called.Source§fn remove_archetype(
state: &mut <Receiver<'_, E, Q> as HandlerParam>::State,
arch: &Archetype,
)
fn remove_archetype( state: &mut <Receiver<'_, E, Q> as HandlerParam>::State, arch: &Archetype, )
Remove the given archetype for this handler param. Called whenever
Handler::remove_archetype
is called.impl<'a, E, Q> Copy for Receiver<'a, E, Q>where
E: Copy + Event,
Q: Copy + ReceiverQuery + 'static,
<E as Event>::This<'a>: Copy,
<Q as ReceiverQuery>::Item<'a>: Copy,
Auto Trait Implementations§
impl<'a, E, Q> Freeze for Receiver<'a, E, Q>
impl<'a, E, Q> RefUnwindSafe for Receiver<'a, E, Q>
impl<'a, E, Q> Send for Receiver<'a, E, Q>
impl<'a, E, Q> Sync for Receiver<'a, E, Q>
impl<'a, E, Q> Unpin for Receiver<'a, E, Q>
impl<'a, E, Q> UnwindSafe for Receiver<'a, E, Q>
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