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
/// A FASTQ record definition.
///
/// A definition represents a definition line, i.e., a read name and, optionally, a description.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Definition {
    name: Vec<u8>,
    description: Vec<u8>,
}

impl Definition {
    /// Creates a FASTQ record definition.
    pub fn new<N, D>(name: N, description: D) -> Self
    where
        N: Into<Vec<u8>>,
        D: Into<Vec<u8>>,
    {
        Self {
            name: name.into(),
            description: description.into(),
        }
    }

    /// Returns the record name.
    pub fn name(&self) -> &[u8] {
        &self.name
    }

    /// Returns a mutable reference to the record name.
    pub fn name_mut(&mut self) -> &mut Vec<u8> {
        &mut self.name
    }

    /// Returns the description.
    pub fn description(&self) -> &[u8] {
        &self.description
    }

    /// Returns a mutable reference to the description.
    pub fn description_mut(&mut self) -> &mut Vec<u8> {
        &mut self.description
    }

    pub(crate) fn clear(&mut self) {
        self.name.clear();
        self.description.clear();
    }
}