pub struct EventLog<Id> { /* private fields */ }Expand description
Event log for tracking outliner interactions.
This structure maintains a circular buffer of recent events, automatically discarding old events when the maximum capacity is reached.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::<u64>::new(100);
log.log("Node 5 selected", EventType::Selection, Some(5));
log.log("Node 3 renamed to 'New Name'", EventType::Rename, Some(3));
assert_eq!(log.len(), 2);
for entry in log.entries() {
println!("{}: {}", entry.event_type_str(), entry.message);
}Implementations§
Source§impl<Id> EventLog<Id>
impl<Id> EventLog<Id>
Sourcepub fn log(
&mut self,
message: impl Into<String>,
event_type: EventType,
node_id: Option<Id>,
)
pub fn log( &mut self, message: impl Into<String>, event_type: EventType, node_id: Option<Id>, )
Logs a new event.
The event is added to the front of the log (most recent). If the log is at capacity, the oldest event is removed.
§Arguments
message- Human-readable description of the eventevent_type- The type of eventnode_id- Optional ID of the node involved
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::new(10);
log.log("Selected node 5", EventType::Selection, Some(5u64));Sourcepub fn entries(&self) -> impl Iterator<Item = &LogEntry<Id>>
pub fn entries(&self) -> impl Iterator<Item = &LogEntry<Id>>
Returns a slice of all log entries, with most recent first.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::new(10);
log.log("Event 1", EventType::Selection, Some(1u64));
log.log("Event 2", EventType::Rename, Some(2u64));
assert_eq!(log.entries().count(), 2);
let entries: Vec<_> = log.entries().collect();
assert_eq!(entries[0].message, "Event 2"); // Most recent firstSourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries in the log.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::<u64>::new(10);
assert_eq!(log.len(), 0);
log.log("Event", EventType::Selection, None);
assert_eq!(log.len(), 1);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the log contains no entries.
§Examples
use egui_arbor::event_log::EventLog;
let log = EventLog::<u64>::new(10);
assert!(log.is_empty());Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all entries from the log.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::<u64>::new(10);
log.log("Event", EventType::Selection, None);
assert!(!log.is_empty());
log.clear();
assert!(log.is_empty());Sourcepub fn max_entries(&self) -> usize
pub fn max_entries(&self) -> usize
Returns the maximum number of entries this log can hold.
§Examples
use egui_arbor::event_log::EventLog;
let log = EventLog::<u64>::new(50);
assert_eq!(log.max_entries(), 50);Sourcepub fn set_max_entries(&mut self, max_entries: usize)
pub fn set_max_entries(&mut self, max_entries: usize)
Sets the maximum number of entries this log can hold.
If the new maximum is less than the current number of entries, the oldest entries are removed to fit the new limit.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::new(10);
for i in 0..10 {
log.log(format!("Event {}", i), EventType::Selection, Some(i));
}
log.set_max_entries(5);
assert_eq!(log.len(), 5);Sourcepub fn filter_by_type(
&self,
event_type: &EventType,
) -> impl Iterator<Item = &LogEntry<Id>>
pub fn filter_by_type( &self, event_type: &EventType, ) -> impl Iterator<Item = &LogEntry<Id>>
Filters entries by event type.
Returns an iterator over entries matching the specified event type.
§Examples
use egui_arbor::event_log::{EventLog, EventType};
let mut log = EventLog::new(10);
log.log("Selected", EventType::Selection, Some(1u64));
log.log("Renamed", EventType::Rename, Some(2u64));
log.log("Selected again", EventType::Selection, Some(3u64));
let selections: Vec<_> = log.filter_by_type(&EventType::Selection).collect();
assert_eq!(selections.len(), 2);