noodles_vcf/variant/record_buf/
alternate_bases.rs1use std::io;
2
3#[derive(Clone, Debug, Default, PartialEq, Eq)]
5pub struct AlternateBases(Vec<String>);
6
7impl AsRef<[String]> for AlternateBases {
8 fn as_ref(&self) -> &[String] {
9 &self.0
10 }
11}
12
13impl AsMut<Vec<String>> for AlternateBases {
14 fn as_mut(&mut self) -> &mut Vec<String> {
15 &mut self.0
16 }
17}
18
19impl From<Vec<String>> for AlternateBases {
20 fn from(alleles: Vec<String>) -> Self {
21 Self(alleles)
22 }
23}
24
25impl crate::variant::record::AlternateBases for AlternateBases {
26 fn is_empty(&self) -> bool {
27 self.0.is_empty()
28 }
29
30 fn len(&self) -> usize {
31 self.0.len()
32 }
33
34 fn iter(&self) -> Box<dyn Iterator<Item = io::Result<&str>> + '_> {
35 Box::new(self.0.iter().map(|allele| allele.as_ref()).map(Ok))
36 }
37}
38
39impl crate::variant::record::AlternateBases for &AlternateBases {
40 fn is_empty(&self) -> bool {
41 self.0.is_empty()
42 }
43
44 fn len(&self) -> usize {
45 self.0.len()
46 }
47
48 fn iter(&self) -> Box<dyn Iterator<Item = io::Result<&str>> + '_> {
49 Box::new(self.0.iter().map(|allele| allele.as_ref()).map(Ok))
50 }
51}