LogEntry

Struct LogEntry 

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

When the event occurred.

§message: String

Human-readable description of the event.

§event_type: EventType

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

Source

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

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

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

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§

Source§

impl<Id: Clone> Clone for LogEntry<Id>

Source§

fn clone(&self) -> LogEntry<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 LogEntry<Id>

Source§

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

Formats the value using the given formatter. Read more

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