#[non_exhaustive]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct ThreadLog {
pub thread_log_id: u64,
pub total_events: u64,
pub lost_events: u64,
pub allocated_histogram: Vec<u64>,
pub live_histogram: Vec<u64>,
}
#[doc(hidden)]
#[derive(Debug)]
pub struct ThreadLogFields {
pub thread_log_id: u64,
pub total_events: u64,
pub lost_events: u64,
pub allocated_histogram: Vec<u64>,
pub live_histogram: Vec<u64>,
}
impl ThreadLog {
#[doc(hidden)]
#[must_use]
pub fn from_fields(fields: ThreadLogFields) -> Self {
let ThreadLogFields {
thread_log_id,
total_events,
lost_events,
allocated_histogram,
live_histogram,
} = fields;
Self {
thread_log_id,
total_events,
lost_events,
allocated_histogram,
live_histogram,
}
}
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[non_exhaustive]
pub enum EventKind {
#[default]
Allocated,
Deallocated,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[non_exhaustive]
pub enum HeapKind {
#[default]
General,
Bump,
Thread,
}
#[non_exhaustive]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Event {
pub thread_log_id: u64,
pub event_thread_id: u64,
pub sequence: u64,
pub allocation_id: u64,
pub kind: EventKind,
pub heap_id: u64,
pub heap_kind: HeapKind,
pub freed_after_heap_release: bool,
pub address: u64,
pub size: u64,
pub align: u64,
pub call_stack: Vec<u64>,
}
#[doc(hidden)]
#[derive(Debug)]
pub struct EventFields {
pub thread_log_id: u64,
pub event_thread_id: u64,
pub sequence: u64,
pub allocation_id: u64,
pub kind: EventKind,
pub heap_id: u64,
pub heap_kind: HeapKind,
pub freed_after_heap_release: bool,
pub address: u64,
pub size: u64,
pub align: u64,
pub call_stack: Vec<u64>,
}
impl Event {
#[doc(hidden)]
#[must_use]
pub fn from_fields(fields: EventFields) -> Self {
let EventFields {
thread_log_id,
event_thread_id,
sequence,
allocation_id,
kind,
heap_id,
heap_kind,
freed_after_heap_release,
address,
size,
align,
call_stack,
} = fields;
Self {
thread_log_id,
event_thread_id,
sequence,
allocation_id,
kind,
heap_id,
heap_kind,
freed_after_heap_release,
address,
size,
align,
call_stack,
}
}
}
#[non_exhaustive]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct ThreadName {
pub thread_id: u64,
pub name: String,
}
#[doc(hidden)]
#[derive(Debug)]
pub struct ThreadNameFields {
pub thread_id: u64,
pub name: String,
}
impl ThreadName {
#[doc(hidden)]
#[must_use]
pub fn from_fields(fields: ThreadNameFields) -> Self {
let ThreadNameFields { thread_id, name } = fields;
Self { thread_id, name }
}
}
#[non_exhaustive]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Callers {
pub session_id: u64,
pub total_events: u64,
pub lost_events: u64,
pub threads: Vec<ThreadLog>,
pub events: Vec<Event>,
pub thread_names: Vec<ThreadName>,
}
#[doc(hidden)]
#[derive(Debug)]
pub struct CallersFields {
pub session_id: u64,
pub total_events: u64,
pub lost_events: u64,
pub threads: Vec<ThreadLog>,
pub events: Vec<Event>,
pub thread_names: Vec<ThreadName>,
}
impl Callers {
#[doc(hidden)]
#[must_use]
pub fn from_fields(fields: CallersFields) -> Self {
let CallersFields {
session_id,
total_events,
lost_events,
threads,
events,
thread_names,
} = fields;
Self {
session_id,
total_events,
lost_events,
threads,
events,
thread_names,
}
}
}
#[non_exhaustive]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct AddressLookup {
pub address: u64,
pub symbol: Option<String>,
pub filename: Option<String>,
pub line: Option<u32>,
pub column: Option<u32>,
}
#[doc(hidden)]
#[derive(Debug)]
pub struct AddressLookupFields {
pub address: u64,
pub symbol: Option<String>,
pub filename: Option<String>,
pub line: Option<u32>,
pub column: Option<u32>,
}
impl AddressLookup {
#[doc(hidden)]
#[must_use]
pub fn from_fields(fields: AddressLookupFields) -> Self {
let AddressLookupFields {
address,
symbol,
filename,
line,
column,
} = fields;
Self {
address,
symbol,
filename,
line,
column,
}
}
}