Skip to main content

format_reply

Function format_reply 

Source
pub fn format_reply(reply: &Reply, indent: usize) -> String
Expand description

Pretty-print a reply roughly the way redis-cli does. Arrays are numbered + indented; bulk strings are quoted; nil shows as (nil).

use kevy_cli::{Reply, format_reply};
assert_eq!(format_reply(&Reply::Nil, 0), "(nil)");
assert_eq!(format_reply(&Reply::Int(3), 0), "(integer) 3");
let nested = Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Array(vec![Reply::Int(1)])]);
assert_eq!(format_reply(&nested, 0), "1) \"a\"\n2)    1) (integer) 1");