libdd_profiling/internal/
function.rs1use super::*;
5
6#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
10pub struct Function {
11 pub name: StringId,
12 pub system_name: StringId,
13 pub filename: StringId,
14}
15
16impl Item for Function {
17 type Id = FunctionId;
18}
19
20#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
21#[repr(C)]
22pub struct FunctionId(NonZeroU32);
23
24impl Id for FunctionId {
25 type RawId = u64;
26
27 fn from_offset(offset: usize) -> Self {
28 #[allow(clippy::expect_used)]
29 Self(small_non_zero_pprof_id(offset).expect("FunctionId to fit into a u32"))
30 }
31
32 fn to_raw_id(&self) -> Self::RawId {
33 self.0.get().into()
34 }
35}