Skip to main content

IntoNativeHandler

Trait IntoNativeHandler 

Source
pub trait IntoNativeHandler {
    // Required method
    fn into_handler(self) -> Option<NativeHandler>;
}
Expand description

add_native 第二个参数的 trait 重载。

既支持按内建名挂载(add_native("local/h", "fight"),查 builtin_native), 也支持直接挂任意 Fn 闭包(add_native("local/h", |msg| { ... }),可带捕获)。 顶层 fn 也会走闭包分支(无捕获闭包)。

Required Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IntoNativeHandler for &str

&str:按内建名查找(如 “fight”)。未知名返回 None,add_native 返回 false。

Implementors§

Source§

impl<F> IntoNativeHandler for F
where F: Fn(Dynamic) -> Dynamic + Send + Sync + 'static,

任意 Fn(Dynamic) -> Dynamic + Send + Sync 闭包(含无捕获的顶层 fn)。 允许 root::add_native("local/h", |msg| { ... }) 直接挂闭包。