noodles_vcf/header/record/value/map/contig/
builder.rs

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
use super::Contig;
use crate::header::record::value::map::{self, builder::BuildError};

#[derive(Default)]
pub struct Builder {
    length: Option<usize>,
    md5: Option<String>,
    url: Option<String>,
    idx: Option<usize>,
}

impl map::builder::Inner<Contig> for Builder {
    fn build(self) -> Result<Contig, BuildError> {
        Ok(Contig {
            length: self.length,
            md5: self.md5,
            url: self.url,
            idx: self.idx,
        })
    }
}

impl map::builder::Indexed<Contig> for Builder {
    fn set_idx(mut self, idx: usize) -> Self {
        self.idx = Some(idx);
        self
    }
}

impl map::Builder<Contig> {
    /// Sets the length.
    pub fn set_length(mut self, length: usize) -> Self {
        self.inner.length = Some(length);
        self
    }

    /// Sets the MD5 hexdigest.
    pub fn set_md5<D>(mut self, md5: D) -> Self
    where
        D: Into<String>,
    {
        self.inner.md5 = Some(md5.into());
        self
    }

    /// Set the URL.
    pub fn set_url<U>(mut self, url: U) -> Self
    where
        U: Into<String>,
    {
        self.inner.url = Some(url.into());
        self
    }
}