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
/// Defines the unique key and identity of each table row.
///
/// This trait must be implemented for any type you want to use as a row in a table.
/// The key is used by Dioxus for efficient rendering and should uniquely identify each row.
///
/// # Example
///
/// ```
/// use dioxus_tabular::Row;
///
/// #[derive(Clone, PartialEq)]
/// struct User {
/// id: u32,
/// name: String,
/// }
///
/// impl Row for User {
/// fn key(&self) -> impl Into<String> {
/// self.id.to_string()
/// }
/// }
/// ```
/// Provides typed access to row data.
///
/// This trait allows columns to extract specific data from rows in a type-safe way.
/// Implement this trait for each piece of data you want to access in your columns.
///
/// # Type Parameter
///
/// - `T`: The type of data to extract from the row
///
/// # Example
///
/// ```
/// use dioxus_tabular::GetRowData;
///
/// #[derive(Clone, PartialEq)]
/// struct User {
/// id: u32,
/// name: String,
/// email: String,
/// }
///
/// // Define accessor types
/// #[derive(Clone, PartialEq)]
/// struct UserName(String);
///
/// #[derive(Clone, PartialEq)]
/// struct UserEmail(String);
///
/// // Implement GetRowData for each accessor
/// impl GetRowData<UserName> for User {
/// fn get(&self) -> UserName {
/// UserName(self.name.clone())
/// }
/// }
///
/// impl GetRowData<UserEmail> for User {
/// fn get(&self) -> UserEmail {
/// UserEmail(self.email.clone())
/// }
/// }
/// ```