bio_streams/
record.rs

1use core::fmt;
2use core::str;
3use futures::Stream;
4
5use crate::FastxError;
6
7#[derive(Debug, PartialEq, Copy, Clone)]
8pub struct Phred(u8);
9
10impl Phred {
11    pub fn to_float(self) -> f32 {
12        unimplemented!()
13    }
14}
15
16impl From<u8> for Phred {
17    fn from(b: u8) -> Phred {
18        Phred(b)
19    }
20}
21
22impl From<Phred> for u8 {
23    fn from(phred: Phred) -> Self {
24        phred.0
25    }
26}
27
28//pub struct Cigar;
29
30#[derive(Debug, PartialEq)]
31pub struct Record<T: for<'a> TryFrom<&'a [u8]> = Vec<u8>> {
32    pub fields: Vec<u8>,
33    pub seq: T,
34    pub quality: Option<Vec<Phred>>,
35}
36
37impl<T: fmt::Display + for<'b> TryFrom<&'b [u8]>> fmt::Display for Record<T> {
38    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
39        write!(
40            f,
41            "{}\t{}",
42            String::from_utf8_lossy(&self.fields),
43            &self.seq,
44        )
45    }
46}
47
48impl<'a, T: for<'b> TryFrom<&'b [u8]>> Record<T> {
49    pub fn name(self) -> &'a str {
50        unimplemented!()
51    }
52
53    pub fn description(self) -> Option<&'a str> {
54        unimplemented!()
55    }
56}
57
58pub trait Reader<T: for<'a> TryFrom<&'a [u8]>>:
59    Iterator<Item = Result<Record<T>, FastxError>> + Stream<Item = Result<Record<T>, FastxError>>
60{
61}