I'm trying to redo a crate that takes in a series of ASCII bytes representing a sequence of RNA bases and produces a sequence of Codon values. I want to be able to do the conversions using the following API. Are there any improvements, including naming, that I could make to the API?```rust
#[derive(...)]
#[repr(u8)]
pub enum Codon {
Aaa,
// ...
Uuu,
}
impl Codon {
pub fn load_vec<P>(path: P) -> Result<Vec<Codon>, SequenceReadError>
where
P: AsRef<Path>,
{
// ...
}
pub fn load_iter<P>(path: P) -> Result<CodonReadIter, SequenceReadError> {
// ...
}
// ...
}
trait Read {
fn read_codon(&mut self) -> Result<Codon, SequenceReadError>;
fn to_codon_vec(&mut self) -> Result<Vec<Codon>, SequenceReadError>;
fn codons(&mut self) -> CodonReadIter;
}
impl<R> Read for R
where
R: std::io::Read,
{
// ...
}
trait Ascii {
fn to_codon_vec(&self) -> Result<Vec<Codon>, SequenceParseError>
fn codons(&self) -> CodonStringlikeIter;
}
impl<A> Ascii for A
where
A: AsRef<[u8]>,
{
// ...
}