EventLog

Struct EventLog 

Source
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>

Source

pub fn new(max_entries: usize) -> Self

Creates a new event log with the specified maximum capacity.

§Arguments
  • max_entries - Maximum number of entries to keep. When this limit is reached, the oldest entries are discarded.
§Examples
use egui_arbor::event_log::EventLog;

let log = EventLog::<u64>::new(50);
Source

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 event
  • event_type - The type of event
  • node_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));
Source

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 first
Source

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);
Source

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());
Source

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());
Source

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);
Source

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);
Source

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);

Trait Implementations§

Source§

impl<Id: Clone> Clone for EventLog<Id>

Source§

fn clone(&self) -> EventLog<Id>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Id: Debug> Debug for EventLog<Id>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Id> Default for EventLog<Id>

Source§

fn default() -> Self

Creates a new event log with a default capacity of 100 entries.

Auto Trait Implementations§

§

impl<Id> Freeze for EventLog<Id>

§

impl<Id> RefUnwindSafe for EventLog<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for EventLog<Id>
where Id: Send,

§

impl<Id> Sync for EventLog<Id>
where Id: Sync,

§

impl<Id> Unpin for EventLog<Id>
where Id: Unpin,

§

impl<Id> UnwindSafe for EventLog<Id>
where Id: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,