1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! API used between RTIC Scope front- and backends.

use chrono::prelude::Local;
use serde::{Deserialize, Serialize};

#[allow(unused_imports)]
use itm_decode::ExceptionAction;
#[allow(unused_imports)]
use itm_decode::TracePacket;

type Timestamp = chrono::DateTime<Local>;

/// A set of events that occurred at a certain timepoint after target
/// reset.
#[derive(Serialize, Deserialize, Debug)]
pub struct EventChunk {
    /// Collective timestamp for the chunk of [EventChunk::events].
    pub timestamp: Timestamp,

    pub events: Vec<EventType>,
}

/// Verbatim copy of [ExceptionAction], sans the enum name.
#[derive(Serialize, Deserialize, Debug)]
pub enum TaskAction {
    /// Task was entered.
    Entered,

    /// Task was exited.
    Exited,

    /// Task was returned to.
    Returned,
}

/// Derivative subset of [TracePacket], where RTIC task information has
/// been resolved.
#[derive(Serialize, Deserialize, Debug)]
pub enum EventType {
    /// [TracePacket::Overflow] equivalent.
    Overflow,

    /// An RTIC task performed an action.
    Task {
        /// What RTIC task did something?
        name: String,

        /// What did the RTIC task do?
        action: TaskAction,
    },
}