1pub(crate) mod fields;
2mod other_fields;
3
4use std::{fmt, io};
5
6use bstr::BStr;
7use noodles_core::Position;
8
9use self::fields::Fields;
10pub use self::other_fields::OtherFields;
11use crate::feature::record::Strand;
12
13#[derive(Clone, Eq, PartialEq)]
15pub struct Record<const N: usize>(pub(crate) Fields<N>);
16
17impl<const N: usize> Record<N> {
18 pub const fn standard_field_count(&self) -> usize {
20 N
21 }
22
23 pub fn other_fields(&self) -> OtherFields<'_, N> {
25 OtherFields::new(&self.0)
26 }
27}
28
29impl Record<3> {
30 pub fn reference_sequence_name(&self) -> &BStr {
32 self.0.reference_sequence_name()
33 }
34
35 pub fn feature_start(&self) -> io::Result<Position> {
37 self.0.feature_start()
38 }
39
40 pub fn feature_end(&self) -> Option<io::Result<Position>> {
42 self.0.feature_end()
43 }
44}
45
46impl Record<4> {
47 pub fn reference_sequence_name(&self) -> &BStr {
49 self.0.reference_sequence_name()
50 }
51
52 pub fn feature_start(&self) -> io::Result<Position> {
54 self.0.feature_start()
55 }
56
57 pub fn feature_end(&self) -> Option<io::Result<Position>> {
59 self.0.feature_end()
60 }
61
62 pub fn name(&self) -> Option<&BStr> {
64 self.0.name()
65 }
66}
67
68impl Record<5> {
69 pub fn reference_sequence_name(&self) -> &BStr {
71 self.0.reference_sequence_name()
72 }
73
74 pub fn feature_start(&self) -> io::Result<Position> {
76 self.0.feature_start()
77 }
78
79 pub fn feature_end(&self) -> Option<io::Result<Position>> {
81 self.0.feature_end()
82 }
83
84 pub fn name(&self) -> Option<&BStr> {
86 self.0.name()
87 }
88
89 pub fn score(&self) -> io::Result<u16> {
91 self.0.score()
92 }
93}
94
95impl Record<6> {
96 pub fn reference_sequence_name(&self) -> &BStr {
98 self.0.reference_sequence_name()
99 }
100
101 pub fn feature_start(&self) -> io::Result<Position> {
103 self.0.feature_start()
104 }
105
106 pub fn feature_end(&self) -> Option<io::Result<Position>> {
108 self.0.feature_end()
109 }
110
111 pub fn name(&self) -> Option<&BStr> {
113 self.0.name()
114 }
115
116 pub fn score(&self) -> io::Result<u16> {
118 self.0.score()
119 }
120
121 pub fn strand(&self) -> io::Result<Option<Strand>> {
123 self.0.strand()
124 }
125}
126
127impl fmt::Debug for Record<3> {
128 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
129 f.debug_struct("Record")
130 .field("reference_sequence_name", &self.reference_sequence_name())
131 .field("feature_start", &self.feature_start())
132 .field("feature_end", &self.feature_end())
133 .field("other_fields", &self.other_fields())
134 .finish()
135 }
136}
137
138impl fmt::Debug for Record<4> {
139 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
140 f.debug_struct("Record")
141 .field("reference_sequence_name", &self.reference_sequence_name())
142 .field("feature_start", &self.feature_start())
143 .field("feature_end", &self.feature_end())
144 .field("name", &self.name())
145 .field("other_fields", &self.other_fields())
146 .finish()
147 }
148}
149
150impl fmt::Debug for Record<5> {
151 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152 f.debug_struct("Record")
153 .field("reference_sequence_name", &self.reference_sequence_name())
154 .field("feature_start", &self.feature_start())
155 .field("feature_end", &self.feature_end())
156 .field("name", &self.name())
157 .field("score", &self.score())
158 .field("other_fields", &self.other_fields())
159 .finish()
160 }
161}
162
163impl fmt::Debug for Record<6> {
164 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
165 f.debug_struct("Record")
166 .field("reference_sequence_name", &self.reference_sequence_name())
167 .field("feature_start", &self.feature_start())
168 .field("feature_end", &self.feature_end())
169 .field("name", &self.name())
170 .field("score", &self.score())
171 .field("strand", &self.strand())
172 .field("other_fields", &self.other_fields())
173 .finish()
174 }
175}
176
177impl Default for Record<3> {
178 fn default() -> Self {
179 Self(Fields::default())
180 }
181}
182
183impl Default for Record<4> {
184 fn default() -> Self {
185 Self(Fields::default())
186 }
187}
188
189impl Default for Record<5> {
190 fn default() -> Self {
191 Self(Fields::default())
192 }
193}
194
195impl Default for Record<6> {
196 fn default() -> Self {
197 Self(Fields::default())
198 }
199}
200
201impl crate::feature::Record<3> for Record<3> {
202 fn reference_sequence_name(&self) -> &BStr {
203 self.reference_sequence_name()
204 }
205
206 fn feature_start(&self) -> io::Result<Position> {
207 self.feature_start()
208 }
209
210 fn feature_end(&self) -> Option<io::Result<Position>> {
211 self.feature_end()
212 }
213
214 fn name(&self) -> Option<Option<&BStr>> {
215 None
216 }
217
218 fn score(&self) -> Option<io::Result<u16>> {
219 None
220 }
221
222 fn strand(&self) -> Option<io::Result<Option<Strand>>> {
223 None
224 }
225
226 fn other_fields(&self) -> Box<dyn crate::feature::record::OtherFields + '_> {
227 Box::new(self.other_fields())
228 }
229}
230
231impl crate::feature::Record<4> for Record<4> {
232 fn reference_sequence_name(&self) -> &BStr {
233 self.reference_sequence_name()
234 }
235
236 fn feature_start(&self) -> io::Result<Position> {
237 self.feature_start()
238 }
239
240 fn feature_end(&self) -> Option<io::Result<Position>> {
241 self.feature_end()
242 }
243
244 fn name(&self) -> Option<Option<&BStr>> {
245 Some(self.name())
246 }
247
248 fn score(&self) -> Option<io::Result<u16>> {
249 None
250 }
251
252 fn strand(&self) -> Option<io::Result<Option<Strand>>> {
253 None
254 }
255
256 fn other_fields(&self) -> Box<dyn crate::feature::record::OtherFields + '_> {
257 Box::new(self.other_fields())
258 }
259}
260
261impl crate::feature::Record<5> for Record<5> {
262 fn reference_sequence_name(&self) -> &BStr {
263 self.reference_sequence_name()
264 }
265
266 fn feature_start(&self) -> io::Result<Position> {
267 self.feature_start()
268 }
269
270 fn feature_end(&self) -> Option<io::Result<Position>> {
271 self.feature_end()
272 }
273
274 fn name(&self) -> Option<Option<&BStr>> {
275 Some(self.name())
276 }
277
278 fn score(&self) -> Option<io::Result<u16>> {
279 Some(self.score())
280 }
281
282 fn strand(&self) -> Option<io::Result<Option<Strand>>> {
283 None
284 }
285
286 fn other_fields(&self) -> Box<dyn crate::feature::record::OtherFields + '_> {
287 Box::new(self.other_fields())
288 }
289}
290
291impl crate::feature::Record<6> for Record<6> {
292 fn reference_sequence_name(&self) -> &BStr {
293 self.reference_sequence_name()
294 }
295
296 fn feature_start(&self) -> io::Result<Position> {
297 self.feature_start()
298 }
299
300 fn feature_end(&self) -> Option<io::Result<Position>> {
301 self.feature_end()
302 }
303
304 fn name(&self) -> Option<Option<&BStr>> {
305 Some(self.name())
306 }
307
308 fn score(&self) -> Option<io::Result<u16>> {
309 Some(self.score())
310 }
311
312 fn strand(&self) -> Option<io::Result<Option<Strand>>> {
313 Some(self.strand())
314 }
315
316 fn other_fields(&self) -> Box<dyn crate::feature::record::OtherFields + '_> {
317 Box::new(self.other_fields())
318 }
319}