use crate::resp::parser::resp_ext::RespVecExt;
pub struct CustomProcedureBase;
impl CustomProcedureBase {
pub fn write_simple_string(output: &mut Vec<u8>, msg: &str) {
output.write_resp_simple_string(msg);
}
pub fn write_bulk_string_array(output: &mut Vec<u8>, items: &[&[u8]]) {
output.write_resp_array_len(items.len());
for item in items {
output.write_resp_bulk_string(item);
}
}
pub fn write_bulk_string(output: &mut Vec<u8>, val: &[u8]) {
output.write_resp_bulk_string(val);
}
pub fn write_null_bulk_string(output: &mut Vec<u8>) {
output.write_resp_null();
}
pub fn write_error(output: &mut Vec<u8>, msg: &str) {
output.write_resp_error(msg);
}
pub fn get_next_arg<'a>(args: &'a [&'a [u8]], idx: &mut usize) -> Option<&'a [u8]> {
if *idx < args.len() {
let res = args[*idx];
*idx += 1;
Some(res)
} else {
None
}
}
pub fn parse_custom_raw_string_command(args: &[&[u8]]) -> bool {
!args.is_empty()
}
pub fn parse_custom_object_command(args: &[&[u8]]) -> bool {
!args.is_empty()
}
pub fn execute_custom_raw_string_command() -> bool {
false
}
pub fn execute_custom_object_command() -> bool {
false
}
}