MCPcopy Create free account
hub / github.com/envoyproxy/dynamic-modules-examples / parse_commands

Method parse_commands

rust/src/network_redis.rs:177–196  ·  view source on GitHub ↗

Parses RESP data and extracts commands.

(data: &[u8])

Source from the content-addressed store, hash-verified

175impl RespParser {
176 /// Parses RESP data and extracts commands.
177 pub fn parse_commands(data: &[u8]) -> Result<Vec<RedisCommand>, &'static str> {
178 let mut commands = Vec::new();
179 let mut pos = 0;
180
181 while pos < data.len() {
182 match Self::parse_resp_value(data, pos) {
183 Ok((value, new_pos)) => {
184 if let Some(cmd) = Self::resp_to_command(value) {
185 commands.push(cmd);
186 }
187 pos = new_pos;
188 }
189 Err(_) => {
190 break;
191 }
192 }
193 }
194
195 Ok(commands)
196 }
197
198 /// Parses a single RESP value starting at the given position.
199 pub fn parse_resp_value(data: &[u8], pos: usize) -> Result<(RespValue, usize), &'static str> {

Callers 1

on_readMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected