Skip to content

Commit

Permalink
sam/record/data/field/value: Move integer parser to a module
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Nov 6, 2024
1 parent ff02a57 commit 8474c64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 2 additions & 10 deletions noodles-sam/src/record/data/field/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
mod array;
pub mod base_modifications;
mod integer;

pub use self::base_modifications::BaseModifications;

use std::io;

use bstr::{BStr, ByteSlice};

use self::array::parse_array;
use self::{array::parse_array, integer::parse_int32_value};
use super::Type;
use crate::alignment::record::data::field::Value;

Expand All @@ -33,15 +34,6 @@ fn parse_character_value<'a>(src: &mut &'a [u8]) -> io::Result<Value<'a>> {
}
}

fn parse_int32_value<'a>(src: &mut &'a [u8]) -> io::Result<Value<'a>> {
let (n, i) = lexical_core::parse_partial(src)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;

*src = &src[i..];

Ok(Value::Int32(n))
}

fn parse_float_value<'a>(src: &mut &'a [u8]) -> io::Result<Value<'a>> {
let (n, i) = lexical_core::parse_partial(src)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
Expand Down
12 changes: 12 additions & 0 deletions noodles-sam/src/record/data/field/value/integer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::io;

use crate::alignment::record::data::field::Value;

pub(super) fn parse_int32_value<'a>(src: &mut &'a [u8]) -> io::Result<Value<'a>> {
let (n, i) = lexical_core::parse_partial(src)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;

*src = &src[i..];

Ok(Value::Int32(n))
}

0 comments on commit 8474c64

Please sign in to comment.