Skip to main content

Event

Struct Event 

Source
pub struct Event {
    pub event_type: String,
    pub data: EventData,
}
Expand description

事件:分发按 event_type 精确匹配,data 直传 handler。

Fields§

§event_type: String

事件类型串,如 "eTick." / "eTick.600000" / crate::EVENT_TIMER。

§data: EventData

载荷;无载荷事件(如 TIMER)默认 EventData 指向 ()。

Implementations§

Source§

impl Event

Source

pub fn new(event_type: impl Into<String>) -> Self

构造无载荷事件(如 Event::new("eTimer"))。

Source

pub fn with_data(event_type: impl Into<String>, data: EventData) -> Self

构造带载荷事件。载荷用 std::sync::Arc::new(your_struct) 包一层。

Trait Implementations§

Source§

impl Debug for Event

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Event

§

impl !UnwindSafe for Event

§

impl Freeze for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

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.