noodles_sam/alignment/record/
data.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
//! Alignment record data.

pub mod field;

use std::io;

use self::field::{Tag, Value};

/// Alignment record data.
pub trait Data {
    /// Returns whether there are any fields.
    fn is_empty(&self) -> bool;

    /// Returns the value for the given tag.
    fn get(&self, tag: &Tag) -> Option<io::Result<Value<'_>>>;

    /// Returns an iterator over fields.
    fn iter(&self) -> Box<dyn Iterator<Item = io::Result<(Tag, Value<'_>)>> + '_>;
}

impl Data for Box<dyn Data + '_> {
    fn is_empty(&self) -> bool {
        (**self).is_empty()
    }

    fn get(&self, tag: &Tag) -> Option<io::Result<Value<'_>>> {
        (**self).get(tag)
    }

    fn iter(&self) -> Box<dyn Iterator<Item = io::Result<(Tag, Value<'_>)>> + '_> {
        (**self).iter()
    }
}