pub struct SaTokenEventBus { /* private fields */ }Expand description
事件总线 - 管理所有监听器并分发事件
Event bus - manages all listeners and dispatches events.
列表用内层 Arc<Vec> 做 publish 快照;配置保持值字段。
Inner Arc<Vec> makes publish a pointer snapshot; config stays a value field.
Implementations§
Source§impl SaTokenEventBus
impl SaTokenEventBus
Sourcepub fn with_config(config: EventBusConfig) -> Self
pub fn with_config(config: EventBusConfig) -> Self
创建事件总线(自定义配置)
Creates an event bus with custom configuration.
Sourcepub fn config(&self) -> &EventBusConfig
pub fn config(&self) -> &EventBusConfig
获取配置引用 | Get configuration reference
Sourcepub fn register(&self, listener: Arc<dyn SaTokenListener>)
pub fn register(&self, listener: Arc<dyn SaTokenListener>)
注册监听器 | Registers a listener.
Sourcepub async fn register_async(&self, listener: Arc<dyn SaTokenListener>)
pub async fn register_async(&self, listener: Arc<dyn SaTokenListener>)
异步注册监听器(为了保持 API 兼容性)
Registers a listener asynchronously (for API compatibility).
Sourcepub fn listener_count(&self) -> usize
pub fn listener_count(&self) -> usize
只读长度。Arc<Vec> Deref 到 Vec,不必为 count 克隆表。
Read len via Deref; never clone the vec just to count.
Sourcepub async fn publish(&self, event: SaTokenEvent)
pub async fn publish(&self, event: SaTokenEvent)
发布事件(按 DispatchMode 分发)
Publishes an event (dispatches according to DispatchMode).
Trait Implementations§
Source§impl Clone for SaTokenEventBus
impl Clone for SaTokenEventBus
Source§fn clone(&self) -> SaTokenEventBus
fn clone(&self) -> SaTokenEventBus
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SaTokenEventBus
impl Debug for SaTokenEventBus
Auto Trait Implementations§
impl Freeze for SaTokenEventBus
impl RefUnwindSafe for SaTokenEventBus
impl Send for SaTokenEventBus
impl Sync for SaTokenEventBus
impl Unpin for SaTokenEventBus
impl UnsafeUnpin for SaTokenEventBus
impl UnwindSafe for SaTokenEventBus
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