MCPcopy Create free account
hub / github.com/Firstyear/opensuse-proxy-cache / array3_parser

Function array3_parser

redis-server/src/parser.rs:115–165  ·  view source on GitHub ↗
(input: &[u8])

Source from the content-addressed store, hash-verified

113}
114
115fn array3_parser(input: &[u8]) -> IResult<&[u8], (Cmd<'_>, usize)> {
116 let mut taken = 0;
117
118 let (rem, (ln, sz)) = line_parser(input)?;
119
120 taken += sz;
121
122 tag("*3")(ln)?;
123
124 // What is the next value? That tells us if we should proceed now or not.
125 let (rem, (itype1, sz)) = type_parser(rem)?;
126 taken += sz;
127
128 match itype1 {
129 IType::BulkString(b"CONFIG") => {
130 let (rem, (itype2, sz)) = type_parser(rem)?;
131 taken += sz;
132 let (rem, (itype3, sz)) = type_parser(rem)?;
133 taken += sz;
134
135 trace!("array3_parser - taken {:?}", taken);
136
137 match (itype2, itype3) {
138 (IType::BulkString(b"GET"), IType::BulkString(key)) => {
139 Ok((rem, (Cmd::ConfigGet(key), taken)))
140 }
141 _ => Ok((rem, (Cmd::Disconnect, taken))),
142 }
143 }
144 IType::BulkString(b"SET") => {
145 let (rem, (itype2, sz)) = type_parser(rem)?;
146 taken += sz;
147
148 trace!("array3_parser - taken {:?}", taken);
149
150 match itype2 {
151 IType::BulkString(key) => {
152 let (rem, (strln, sz)) = bulkstrln_parser(rem)?;
153 taken += sz;
154 trace!("array3_parser - SET - taken {:?}", taken);
155
156 Ok((rem, (Cmd::Set(key, strln), taken)))
157 } // _ => Ok((rem, (Cmd::Disconnect, taken))),
158 }
159 }
160 _ => Ok((rem, (Cmd::Disconnect, taken))),
161 }
162
163 // do a "first value" parse, capable of reading if it's bulk or simple string.
164 // once we know the first value, can understand the second.
165}
166
167fn array2_parser(input: &[u8]) -> IResult<&[u8], (Cmd<'_>, usize)> {
168 // The *2 parser then checks the first element

Callers

nothing calls this directly

Calls 3

line_parserFunction · 0.85
type_parserFunction · 0.85
bulkstrln_parserFunction · 0.85

Tested by

no test coverage detected