@@ -2,6 +2,7 @@ use crate::Frame;
2
2
3
3
use bytes:: Bytes ;
4
4
use std:: { fmt, str, vec} ;
5
+ use tracing:: instrument;
5
6
6
7
/// Utility for parsing a command
7
8
///
@@ -33,6 +34,7 @@ impl Parse {
33
34
/// Create a new `Parse` to parse the contents of `frame`.
34
35
///
35
36
/// Returns `Err` if `frame` is not an array frame.
37
+ #[ instrument( level = "trace" , name = "Parse::new" ) ]
36
38
pub ( crate ) fn new ( frame : Frame ) -> Result < Parse , ParseError > {
37
39
let array = match frame {
38
40
Frame :: Array ( array) => array,
@@ -46,13 +48,15 @@ impl Parse {
46
48
47
49
/// Return the next entry. Array frames are arrays of frames, so the next
48
50
/// entry is a frame.
51
+ #[ instrument( level = "trace" , name = "Parse::next" , skip( self ) ) ]
49
52
fn next ( & mut self ) -> Result < Frame , ParseError > {
50
53
self . parts . next ( ) . ok_or ( ParseError :: EndOfStream )
51
54
}
52
55
53
56
/// Return the next entry as a string.
54
57
///
55
58
/// If the next entry cannot be represented as a String, then an error is returned.
59
+ #[ instrument( level = "trace" , name = "Parse::next_string" , skip( self ) ) ]
56
60
pub ( crate ) fn next_string ( & mut self ) -> Result < String , ParseError > {
57
61
match self . next ( ) ? {
58
62
// Both `Simple` and `Bulk` representation may be strings. Strings
@@ -76,6 +80,7 @@ impl Parse {
76
80
///
77
81
/// If the next entry cannot be represented as raw bytes, an error is
78
82
/// returned.
83
+ #[ instrument( level = "trace" , name = "Parse::next_bytes" , skip( self ) ) ]
79
84
pub ( crate ) fn next_bytes ( & mut self ) -> Result < Bytes , ParseError > {
80
85
match self . next ( ) ? {
81
86
// Both `Simple` and `Bulk` representation may be raw bytes.
@@ -99,6 +104,7 @@ impl Parse {
99
104
///
100
105
/// If the next entry cannot be represented as an integer, then an error is
101
106
/// returned.
107
+ #[ instrument( level = "trace" , name = "Parse::next_int" , skip( self ) ) ]
102
108
pub ( crate ) fn next_int ( & mut self ) -> Result < u64 , ParseError > {
103
109
use atoi:: atoi;
104
110
@@ -116,6 +122,7 @@ impl Parse {
116
122
}
117
123
118
124
/// Ensure there are no more entries in the array
125
+ #[ instrument( level = "trace" , name = "Parse::finish" , skip( self ) ) ]
119
126
pub ( crate ) fn finish ( & mut self ) -> Result < ( ) , ParseError > {
120
127
if self . parts . next ( ) . is_none ( ) {
121
128
Ok ( ( ) )
0 commit comments