deepbiop_fa/encode/
record.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
use bstr::BString;
use derive_builder::Builder;

#[derive(Debug, Default, Builder)]
pub struct RecordData {
    pub id: BString,
    pub seq: BString,
}

impl RecordData {
    pub fn new(id: BString, seq: BString) -> Self {
        Self { id, seq }
    }
}

impl From<(Vec<u8>, Vec<u8>)> for RecordData {
    fn from(data: (Vec<u8>, Vec<u8>)) -> Self {
        Self::new(data.0.into(), data.1.into())
    }
}

impl From<(BString, BString)> for RecordData {
    fn from(data: (BString, BString)) -> Self {
        Self::new(data.0, data.1)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_record_data_build() {
        let record = RecordDataBuilder::default()
            .id("id".into())
            .seq("seq".into())
            .build()
            .unwrap();

        assert_eq!(record.id, "id");
        assert_eq!(record.seq, "seq");
    }
}