redis-on-mysql 0.0.1

A Redis-compatible proxy that stores all data and Pub/Sub state in MySQL
Documentation
use bytes::Bytes;
use resp_async::response::RespError;
use resp_async::{Cmd, Value};

use crate::handlers::util::{pong, wrong_arity};

pub async fn ping(Cmd(cmd): Cmd) -> Result<Value, RespError> {
    match cmd.args.len() {
        0 => Ok(pong()),
        1 => match cmd.args.first().unwrap() {
            Value::Bulk(bytes) | Value::Simple(bytes) => Ok(Value::Bulk(bytes.clone())),
            Value::Integer(value) => Ok(Value::Bulk(Bytes::from(value.to_string()))),
            _ => Err(RespError::invalid_data("ERR invalid PING payload")),
        },
        _ => Err(wrong_arity("PING")),
    }
}

pub async fn quit() -> Value {
    // resp-async does not expose a direct connection-close hook for handlers.
    Value::Simple(Bytes::from_static(b"OK"))
}