@@ -6,10 +6,10 @@ use crate::{parsed::Signature, Time};
6
6
use bstr:: { BStr , ByteSlice } ;
7
7
use btoi:: btoi;
8
8
use hex:: FromHex ;
9
- use nom:: { bytes:: complete:: tag, IResult , } ;
10
- use nom:: sequence:: { tuple, preceded, terminated} ;
11
9
use nom:: bytes:: complete:: { take, take_while, take_while_m_n} ;
12
10
use nom:: combinator:: map;
11
+ use nom:: sequence:: { preceded, terminated, tuple} ;
12
+ use nom:: { bytes:: complete:: tag, IResult } ;
13
13
14
14
#[ derive( PartialEq , Eq , Debug , Hash ) ]
15
15
pub struct Tag < ' data > {
@@ -75,10 +75,6 @@ fn parse_signature(d: &[u8]) -> Result<Signature, Error> {
75
75
} )
76
76
}
77
77
78
- fn context ( msg : & ' static str ) -> impl Fn ( nom:: Err < Error > ) -> nom:: Err < Error > {
79
- move |e : nom:: Err < Error > | e. map ( |e| e. parse_context ( msg) )
80
- }
81
-
82
78
fn is_hex_digit_lc ( b : u8 ) -> bool {
83
79
match b {
84
80
b'0' ..=b'9' => true ,
@@ -89,7 +85,14 @@ fn is_hex_digit_lc(b: u8) -> bool {
89
85
90
86
pub ( crate ) fn parse_tag_nom ( i : & [ u8 ] ) -> IResult < & [ u8 ] , Tag , Error > {
91
87
const NL : & [ u8 ] = b"\n " ;
92
- let ( i, _) = terminated ( preceded ( tag ( b"object " ) , take_while_m_n ( 40usize , 40 , is_hex_digit_lc) ) , tag ( NL ) ) ( i) . map_err ( context ( "object <40 lowercase hex char>" ) ) ?;
88
+ let ( i, _) = terminated (
89
+ preceded (
90
+ tag ( b"object " ) ,
91
+ take_while_m_n ( 40usize , 40 , is_hex_digit_lc) ,
92
+ ) ,
93
+ tag ( NL ) ,
94
+ ) ( i)
95
+ . map_err ( Error :: context ( "object <40 lowercase hex char>" ) ) ?;
93
96
unimplemented ! ( "parse message nom" )
94
97
}
95
98
0 commit comments