Trait evenio::event::Event

source ·
pub unsafe trait Event {
    type This<'a>: 'a;
    type EventIdx: EventIdxMarker;
    type Mutability: MutabilityMarker;

    // Provided method
    fn init(world: &mut World) -> EventKind { ... }
}
Expand description

Messages which event handlers listen for. This is the base trait of GlobalEvent and TargetedEvent.

To send and receive events within handlers, see Sender and Receiver.

§Safety

This trait is unsafe to implement because unsafe code relies on correct implementations of This and init to avoid undefined behavior. Note that implementations produced by the derive macros are always safe.

Required Associated Types§

source

type This<'a>: 'a

The type of Self, but with lifetimes modified to outlive 'a.

§Safety

This type must correspond to the type of Self. In particular, it must be safe to transmute between Self and This<'a> (assuming 'a is correct). Additionally, the TypeId of Self must match that of This<'static>.

source

type EventIdx: EventIdxMarker

Either GlobalEventIdx or TargetedEventIdx. This indicates if the event is global or targeted.

source

type Mutability: MutabilityMarker

Indicates if this event is Mutable or Immutable.

Immutable events disallow mutable references to the event and ownership transfer via EventMut::take. This is useful for ensuring events are not altered during their lifespan.

Provided Methods§

source

fn init(world: &mut World) -> EventKind

Gets the EventKind of this event and performs any necessary initialization work.

§Safety

Although this method is safe to call, it is unsafe to implement because unsafe code relies on the returned EventKind being correct for this type. Additionally, the world cannot be used in ways that would result in dangling indices during handler initialization.

The exact safety requirements are currently unspecified, but the default implementation returns EventKind::Normal and is always safe.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Event for AddComponent

source§

impl Event for RemoveComponent

source§

impl Event for AddHandler

source§

impl Event for RemoveHandler

source§

impl Event for AddGlobalEvent

source§

impl Event for AddTargetedEvent

source§

impl Event for Despawn

source§

impl Event for RemoveGlobalEvent

source§

impl Event for RemoveTargetedEvent

source§

impl Event for Spawn

source§

impl<C: Component> Event for Remove<C>

source§

impl<C: Component> Event for Insert<C>