Use a Response enum
clarity0 opened this issue · 4 comments
clarity0 commented
Currently every response is formatted independently
I think it would be better to implement a struct to do this.
evoxmusic commented
What do you mean by a "responder struct"?
clarity0 commented
pub enum RedisResponse {
Integer(u32),
SimpleString(String),
BulkString(String),
Array(Vec<RedisResponse>),
}
impl RedisResponse {
fn respond(&self) -> Vec<u8>{
match data {
...
}
}
}
Something like this, this way no matter what the response type is, the handling of the formatting of the response delegated to the Respond function and away from the logic of the commands.
evoxmusic commented
I agree with that. It will be clearer for everyone