mod error;
pub use self::error::*;
use crate::{extract::Extract, Event, StateChange, TryExtract};
use std::mem::transmute;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LogEvent {
pub time: u64,
pub server_time: u32,
pub local_time: u32,
pub id: u64,
}
impl Extract for LogEvent {
#[inline]
unsafe fn extract(event: &Event) -> Self {
Self {
time: event.time,
server_time: transmute(event.value),
local_time: transmute(event.buff_dmg),
id: event.src_agent,
}
}
}
impl TryExtract for LogEvent {
#[inline]
fn can_extract(event: &Event) -> bool {
matches!(
event.get_statechange(),
StateChange::LogStart | StateChange::LogEnd | StateChange::LogNPCUpdate
)
}
}