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

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

impl map::builder::Inner<Contig> for Builder {
    fn build(self) -> Result<Contig, BuildError> {
        Ok(Contig {
            length: self.length,
            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
    }
}