evtc\log/
arc_build.rs

1use crate::{
2    extract::{transmute_field, Extract},
3    Event, StateChange, TryExtract,
4};
5
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9/// ArcDPS log error.
10#[derive(Debug, Clone)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub struct ArcBuildEvent {
13    /// ArcDPS build string.
14    pub build: String,
15}
16
17impl ArcBuildEvent {
18    pub const MAX_LEN: usize = 32;
19}
20
21impl Extract for ArcBuildEvent {
22    #[inline]
23    unsafe fn extract(event: &Event) -> Self {
24        let bytes = transmute_field!(event.time as [u8; ArcBuildEvent::MAX_LEN]);
25
26        Self {
27            build: String::from_utf8_lossy(&bytes)
28                .trim_end_matches('\0')
29                .into(),
30        }
31    }
32}
33
34impl TryExtract for ArcBuildEvent {
35    #[inline]
36    fn can_extract(event: &Event) -> bool {
37        event.get_statechange() == StateChange::Integrity
38    }
39}