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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
use ;
use ;
/// Represents an annotation with content and a timestamp.
///
/// # Fields
///
/// - `content`: The textual content of the annotation. It can be any valid string, allowing you to
/// provide context, notes etc.
///
/// - `created_at`: The timestamp when the annotation was created, measured in milliseconds since the
/// Unix epoch. This timestamp provides a point in time reference for when the annotation
/// was added or recorded.
///
/// # Examples
///
/// ```
/// let annotation = Annotation {
/// content: "This is an example annotation.".to_string(),
/// created_at: 1632172800000, // Timestamp in milliseconds
/// };
/// ```
/// Implements the conversion from a `&String` to an `Annotation` struct.
///
/// This conversion allows you to create an `Annotation` from a string that follows a specific
/// format used in metadata files. Annotations in the metadata file are stored in the following
/// format:
///
/// ```text
/// <TIMESTAMP> <CONTENT>
/// ```
///
/// Where:
///
/// - `<TIMESTAMP>`: Represents a valid u128 number that serves as the timestamp of the annotation.
/// - `<CONTENT>`: Represents the textual content of the annotation as a valid string.
///
/// To parse an annotation, this implementation locates the first space character in the string.
/// Since the timestamp is a contiguous sequence of characters, this space character indicates the
/// separation between the annotation's timestamp and its content.
///
/// However, it's important to note that if an annotation is ever stored in an invalid format, such
/// as when the annotation's timestamp is missing, certain issues may arise:
///
/// - The character space between the timestamp and content may not be found at all.
/// - A character space from within the annotation's content might be incorrectly identified as
/// the separator between the supposed timestamp and its content.
///
/// # Errors
///
/// If the provided string cannot be successfully parsed into an `Annotation`, this conversion
/// will panic with an error message indicating the cause of the failure.
///
/// # Examples
///
/// ```rust
/// let annotation_string = "1632172800000 This is an example annotation.".to_string();
/// let annotation: Annotation = (&annotation_string).into();
/// println!("{}", annotation);
/// ```
/// Implements the `Display` trait for the `Annotation` struct.
///
/// This trait allows you to customize how an `Annotation` is formatted when it is displayed
/// as a string. In this implementation, an `Annotation` is represented as a tuple-like structure:
///
/// ```text
/// (<TIMESTAMP>, <CONTENT>)
/// ```
///
/// Where:
///
/// - `<TIMESTAMP>`: Represents the timestamp of the annotation.
/// - `<CONTENT>`: Represents the textual content of the annotation.
///
/// This format is designed for easy and human-readable representation of annotations when they
/// need to be printed, logged, or otherwise displayed as strings.
///
/// # Examples
///
/// ```rust
/// let annotation = Annotation {
/// created_at: 1632172800000,
/// content: "This is an example annotation.".to_string(),
/// };
///
/// let formatted_annotation = format!("{}", annotation);
/// println!("{}", formatted_annotation); // Prints: "(1632172800000, This is an example annotation.)"
/// ```
///
/// # Note
///
/// - This implementation is primarily intended for human-readable output and debugging purposes.
/// - The `<TIMESTAMP>` and `<CONTENT>` placeholders represent the actual timestamp and content
/// of the annotation.