use std::borrow::Cow;
use std::num::NonZeroU32;
use std::time::Duration;
#[derive(Debug)]
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[serde(tag = "type")]
pub enum FunctionTrace<'event> {
RegisterThread(ThreadRegistration),
Call {
time: Duration,
#[serde(borrow)]
func_name: Cow<'event, str>,
#[serde(borrow)]
filename: Cow<'event, str>,
linenumber: u32,
},
Return {
time: Duration,
#[serde(borrow)]
func_name: Cow<'event, str>,
},
NativeCall {
time: Duration,
#[serde(borrow)]
func_name: Cow<'event, str>,
#[serde(borrow)]
module_name: Cow<'event, str>,
},
NativeReturn {
time: Duration,
#[serde(borrow)]
func_name: Cow<'event, str>,
},
Exception {
time: Duration,
#[serde(borrow)]
exception_type: Cow<'event, str>,
#[serde(borrow)]
exception_value: Cow<'event, str>,
filename: String,
linenumber: NonZeroU32,
},
Log {
time: Duration,
#[serde(borrow)]
log_type: Cow<'event, str>,
#[serde(borrow)]
log_value: Cow<'event, str>,
},
Import {
time: Duration,
#[serde(borrow)]
module_name: Cow<'event, str>,
},
Allocation {
time: Duration,
details: AllocationDetails,
},
}
#[derive(Debug)]
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[serde(tag = "type")]
pub enum AllocationDetails {
Alloc { bytes: usize, addr: usize },
Realloc {
bytes: usize,
old_addr: usize,
new_addr: usize,
},
Free { old_addr: usize },
}
#[derive(Debug)]
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct TraceInitialization {
pub program_name: String,
pub program_version: String,
pub lang_version: String,
pub platform: String,
pub time: Duration,
}
#[derive(Debug)]
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct ThreadRegistration {
pub time: Duration,
pub program_name: String,
pub pid: usize,
}