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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Compile-time unique component identifiers
//!
//! Provides macros and utilities for generating unique component IDs
//! that can be used with stateful systems without depending on blinc_app.
//!
//! # Usage
//!
//! ```ignore
//! use blinc_cn::component_id;
//!
//! // Generate a unique ID for this call site
//! let id = component_id!();
//!
//! // Generate a unique ID with a suffix
//! let id = component_id!("my_component");
//! ```
//!
//! # Function Scope Awareness
//!
//! The macros include `module_path!()` which captures the full module path
//! including function names when called inside functions, ensuring uniqueness
//! across different scopes.
//!
//! ```ignore
//! mod foo {
//! fn render_a() {
//! let id = component_id!(); // "crate::foo::render_a:file.rs:10:5"
//! }
//! fn render_b() {
//! let id = component_id!(); // "crate::foo::render_b:file.rs:14:5"
//! }
//! }
//! ```
/// Generate a unique compile-time component ID based on module path, file, line, and column
///
/// This macro creates a unique string key that is stable across rebuilds
/// as long as the source location doesn't change. It includes the full module path
/// (including function names when called inside functions) for additional uniqueness.
///
/// # Example
///
/// ```ignore
/// use blinc_cn::component_id;
///
/// // Basic usage - ID based on call site with module path
/// let id = component_id!();
///
/// // With suffix for multiple IDs at same location
/// let id1 = component_id!("button_1");
/// let id2 = component_id!("button_2");
/// ```
/// Generate a unique component ID from a type name
///
/// Uses `module_path!()` and `stringify!()` to create a unique key
/// based on the fully qualified type name.
///
/// # Example
///
/// ```ignore
/// use blinc_cn::component_type_id;
///
/// struct MyButton;
///
/// // Generates: "my_module::MyButton"
/// let id = component_type_id!(MyButton);
/// ```
/// A trait for components that provide their own unique ID
///
/// Implement this for components that need stable identity across rebuilds.
/// Macro to implement ComponentId for a type
///
/// # Example
///
/// ```ignore
/// use blinc_cn::{impl_component_id, ComponentId};
///
/// struct MyCard;
/// impl_component_id!(MyCard);
///
/// // Now MyCard::ID is available
/// assert!(MyCard::ID.contains("MyCard"));
/// ```