Skip to content

Commit 7c1d94e

Browse files
committed
Bump nom dependency to v8.0
1 parent 6b35e4d commit 7c1d94e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

nafcodec/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keywords = ["nucleotide", "archive", "biology", "bioinformatics"]
1212
categories = ["science", "parser-implementations", "compression"]
1313

1414
[dependencies]
15-
nom = "7.1.3"
15+
nom = "8"
1616
[dependencies.zstd]
1717
version = "0.13.1"
1818
features = ["experimental"]

nafcodec/src/decoder/parser.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use nom::IResult;
2+
use nom::Parser;
23

34
use crate::data::Flag;
45
use crate::data::Flags;
@@ -47,11 +48,12 @@ pub fn variable_u64(i: &[u8]) -> IResult<&[u8], u64> {
4748
}
4849

4950
pub fn format_descriptor(i: &[u8]) -> IResult<&[u8], &[u8]> {
50-
nom::bytes::streaming::tag([0x01, 0xF9, 0xEC])(i)
51+
// NOTE: for some reason `nom::bytes::tag`
52+
nom::combinator::verify(nom::bytes::take(3u32), |x: &[u8]| x == &[0x01, 0xF9, 0xEC]).parse(i)
5153
}
5254

5355
pub fn format_version(i: &[u8]) -> IResult<&[u8], FormatVersion> {
54-
match nom::combinator::verify(self::byte, |&byte: &u8| byte == 1 || byte == 2)(i) {
56+
match nom::combinator::verify(self::byte, |&byte: &u8| byte == 1 || byte == 2).parse(i) {
5557
Err(e) => Err(e),
5658
Ok((i, 1)) => Ok((i, FormatVersion::V1)),
5759
Ok((i, 2)) => Ok((i, FormatVersion::V2)),
@@ -60,7 +62,7 @@ pub fn format_version(i: &[u8]) -> IResult<&[u8], FormatVersion> {
6062
}
6163

6264
pub fn sequence_type(i: &[u8]) -> IResult<&[u8], SequenceType> {
63-
match nom::combinator::verify(self::byte, |&byte: &u8| byte <= 0x03)(i) {
65+
match nom::combinator::verify(self::byte, |&byte: &u8| byte <= 0x03).parse(i) {
6466
Err(e) => Err(e),
6567
Ok((i, 0)) => Ok((i, SequenceType::Dna)),
6668
Ok((i, 1)) => Ok((i, SequenceType::Rna)),
@@ -83,7 +85,9 @@ pub fn flags(i: &[u8]) -> IResult<&[u8], Flags> {
8385
}
8486

8587
pub fn name_separator(i: &[u8]) -> IResult<&[u8], char> {
86-
nom::combinator::verify(self::byte, self::is_printable)(i).map(|(i, c)| (i, c as char))
88+
nom::combinator::verify(self::byte, self::is_printable)
89+
.parse(i)
90+
.map(|(i, c)| (i, c as char))
8791
}
8892

8993
pub fn line_length(i: &[u8]) -> IResult<&[u8], u64> {
@@ -129,7 +133,8 @@ pub fn title(i: &[u8]) -> IResult<&[u8], &str> {
129133
let (i, text) = nom::combinator::map_res(
130134
nom::bytes::streaming::take(size as usize),
131135
std::str::from_utf8,
132-
)(i)?;
136+
)
137+
.parse(i)?;
133138
Ok((i, text))
134139
}
135140

0 commit comments

Comments
 (0)