Skip to main content

HandlerRegistry

Struct HandlerRegistry 

Source
pub struct HandlerRegistry { /* private fields */ }
Expand description

handler 注册管理器。线程安全。(含不透明函数对象,不 derive Debug)

Implementations§

Source§

impl HandlerRegistry

Source

pub fn register(&self, event_type: impl Into<String>, f: HandlerFn) -> HandlerId

注册 handler 至指定 event_type,返回全局唯一 HandlerId 供注销。 注意:每次注册都会新增一条(闭包不可比较,原版“函数相等去重“无法复刻); 防重复注册由调用方负责,引擎只保证 id 唯一且可精确注销。

Source

pub fn unregister(&self, id: HandlerId) -> bool

注销 HandlerId,无论挂在哪个 type 下;true 表示确实注销了某个。 类型列表变空时自动从表中移除该 type(对齐原版 pop(type))。

Source

pub fn register_general(&self, f: HandlerFn) -> HandlerId

注册通用 handler;成功返回 HandlerId。

Source

pub fn unregister_general(&self, id: HandlerId) -> bool

注销通用 handler。

Trait Implementations§

Source§

impl Default for HandlerRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.