noodles_fastq/record/definition.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
use bstr::{BStr, BString};
/// 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: BString,
description: BString,
}
impl Definition {
/// Creates a FASTQ record definition.
pub fn new<N, D>(name: N, description: D) -> Self
where
N: Into<BString>,
D: Into<BString>,
{
Self {
name: name.into(),
description: description.into(),
}
}
/// Returns the record name.
pub fn name(&self) -> &BStr {
self.name.as_ref()
}
/// Returns a mutable reference to the record name.
pub fn name_mut(&mut self) -> &mut BString {
&mut self.name
}
/// Returns the description.
pub fn description(&self) -> &BStr {
self.description.as_ref()
}
/// Returns a mutable reference to the description.
pub fn description_mut(&mut self) -> &mut BString {
&mut self.description
}
pub(crate) fn clear(&mut self) {
self.name.clear();
self.description.clear();
}
}