Skip to content

Commit

Permalink
impl AuxFieldSet for EnumField
Browse files Browse the repository at this point in the history
  • Loading branch information
bsaintjo committed Dec 25, 2022
1 parent ffa911b commit cf6c123
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,25 @@ impl AuxFieldSetExt for String {
}
}

impl AuxFieldSetExt for EnumField {
fn aux_set<B>(
&self,
rec: &mut Record,
field: B,
writer: &mut FileWriter,
) -> Result<(), Slow5Error>
where
Self: Sized,
B: Into<Vec<u8>>,
{
if self.0 > (u8::MAX as usize) {
Err(Slow5Error::TooManyLabels(self.0))
} else {
(self.0 as u8).aux_set(rec, field, writer)
}
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit cf6c123

Please sign in to comment.