pub struct LogEntry<Id> {
pub timestamp: SystemTime,
pub message: String,
pub event_type: EventType,
pub node_id: Option<Id>,
}Expand description
A single log entry recording an event.
Each entry contains:
- A timestamp of when the event occurred
- A human-readable message describing the event
- The type of event
- An optional node ID associated with the event
Fields§
§timestamp: SystemTimeWhen the event occurred.
message: StringHuman-readable description of the event.
event_type: EventTypeThe type of event that occurred.
node_id: Option<Id>The ID of the node involved in the event, if applicable.
Implementations§
Source§impl<Id> LogEntry<Id>
impl<Id> LogEntry<Id>
Sourcepub fn new(message: String, event_type: EventType, node_id: Option<Id>) -> Self
pub fn new(message: String, event_type: EventType, node_id: Option<Id>) -> Self
Creates a new log entry.
§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::{LogEntry, EventType};
let entry = LogEntry::new(
"Selected node".to_string(),
EventType::Selection,
Some(42u64),
);Sourcepub fn event_type_str(&self) -> &str
pub fn event_type_str(&self) -> &str
Returns the event type as a string.
§Examples
use egui_arbor::event_log::{LogEntry, EventType};
let entry = LogEntry::<u64>::new("test".into(), EventType::Selection, None);
assert_eq!(entry.event_type_str(), "Selection");Sourcepub fn elapsed(&self) -> Result<Duration, SystemTimeError>
pub fn elapsed(&self) -> Result<Duration, SystemTimeError>
Returns the elapsed time since this event occurred.
§Returns
Ok(Duration) if the elapsed time could be calculated, or an error if
the system time has moved backwards.
§Examples
use egui_arbor::event_log::{LogEntry, EventType};
let entry = LogEntry::<u64>::new("test".into(), EventType::Selection, None);
if let Ok(elapsed) = entry.elapsed() {
println!("Event occurred {} seconds ago", elapsed.as_secs());
}Sourcepub fn format_elapsed(&self) -> String
pub fn format_elapsed(&self) -> String
Formats the elapsed time as a human-readable string.
Returns strings like “5s ago”, “2m ago”, “1h ago”, etc.
§Examples
use egui_arbor::event_log::{LogEntry, EventType};
let entry = LogEntry::<u64>::new("test".into(), EventType::Selection, None);
println!("{}", entry.format_elapsed());Trait Implementations§
Auto Trait Implementations§
impl<Id> Freeze for LogEntry<Id>where
Id: Freeze,
impl<Id> RefUnwindSafe for LogEntry<Id>where
Id: RefUnwindSafe,
impl<Id> Send for LogEntry<Id>where
Id: Send,
impl<Id> Sync for LogEntry<Id>where
Id: Sync,
impl<Id> Unpin for LogEntry<Id>where
Id: Unpin,
impl<Id> UnwindSafe for LogEntry<Id>where
Id: UnwindSafe,
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