memscope_rs/analysis/generic/
types.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct GenericInstance {
5 pub name: String,
6 pub base_type: String,
7 pub underlying_type: String,
8 pub type_parameters: Vec<String>,
9 pub ptr: usize,
10 pub size: usize,
11 pub constraints: Vec<GenericConstraint>,
12 pub is_type_alias: bool,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct GenericConstraint {
17 pub parameter_name: String,
18 pub constraint_type: ConstraintType,
19 pub description: String,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub enum ConstraintType {
24 Trait(String),
25 Lifetime,
26 Sized,
27 Send,
28 Sync,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct InstantiationEvent {
33 pub base_type: String,
34 pub type_parameters: Vec<String>,
35 pub ptr: usize,
36 pub timestamp: u64,
37 pub thread_id: String,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct ConstraintViolation {
42 pub constraint: GenericConstraint,
43 pub actual_type: String,
44 pub violation_type: ViolationType,
45 pub timestamp: u64,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub enum ViolationType {
50 ConstraintNotSatisfied,
51 LifetimeMismatch,
52 MissingTraitImpl,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct GenericStatistics {
57 pub total_instances: usize,
58 pub unique_base_types: usize,
59 pub total_instantiations: usize,
60 pub constraint_violations: usize,
61 pub most_used_types: Vec<(String, usize)>,
62 pub type_aliases_count: usize,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct TypeAliasInfo {
67 pub alias_name: String,
68 pub underlying_type: String,
69 pub base_type: String,
70 pub type_parameters: Vec<String>,
71 pub usage_count: usize,
72}