pub struct EventLog { /* private fields */ }Expand description
环形缓冲事件日志。总闸关闭时不记录;enable(false) 可单独关闭某一棵树。
Implementations§
Source§impl EventLog
impl EventLog
pub fn new() -> Self
Sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
两层开关都为开时才采集。关闭时 Self::push 是 no-op(零分配、零锁)。
Sourcepub fn push(&self, record: EventRecord)
pub fn push(&self, record: EventRecord)
追加一条记录。关闭时立即返回。
Sourcepub fn route(
&self,
event_type: &'static str,
target: Option<ElementId>,
detail: impl Into<String>,
)
pub fn route( &self, event_type: &'static str, target: Option<ElementId>, detail: impl Into<String>, )
追加一条 Route 类记录(dispatch_event 入口)。
Sourcepub fn deliver(
&self,
event_type: &'static str,
target: ElementId,
detail: impl Into<String>,
)
pub fn deliver( &self, event_type: &'static str, target: ElementId, detail: impl Into<String>, )
追加一条 Deliver 类记录。
Sourcepub fn consumed(
&self,
event_type: &'static str,
chain: &[ElementId],
consumed_by: Option<ElementId>,
)
pub fn consumed( &self, event_type: &'static str, chain: &[ElementId], consumed_by: Option<ElementId>, )
追加一条 Consume 类记录:事件冒泡/定向投递后被谁消费了。
接收切片而不是 Vec:关闭时调用点不必先 clone 整条链。
Sourcepub fn focus(
&self,
old: Option<ElementId>,
new: Option<ElementId>,
visible: Option<bool>,
)
pub fn focus( &self, old: Option<ElementId>, new: Option<ElementId>, visible: Option<bool>, )
追加一条 Focus 类记录。
Sourcepub fn gesture(&self, winner: Option<ElementId>, detail: impl Into<String>)
pub fn gesture(&self, winner: Option<ElementId>, detail: impl Into<String>)
追加一条 Gesture 类记录(竞技场胜者 / reject)。
Sourcepub fn snapshot(&self, max: usize) -> Vec<EventRecord>
pub fn snapshot(&self, max: usize) -> Vec<EventRecord>
取最近 N 条快照(devtools 面板每 250ms 调一次)。取 all 留 0。
总闸关闭时返回空,避免面板关闭期间仍读到旧记录。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EventLog
impl Forget for EventLog
impl Move for EventLog
impl RefUnwindSafe for EventLog
impl Send for EventLog
impl Sync for EventLog
impl Unpin for EventLog
impl UnsafeUnpin for EventLog
impl UnwindSafe for EventLog
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