implement client ping (#108)

This commit is contained in:
Kim Chan
2022-08-25 17:10:32 +08:00
committed by GitHub
parent d3826795af
commit c1c3bcb465
4 changed files with 84 additions and 1 deletions

View File

@@ -63,4 +63,17 @@ impl Ping {
Ok(())
}
/// Converts the command into an equivalent `Frame`.
///
/// This is called by the client when encoding a `Ping` command to send
/// to the server.
pub(crate) fn into_frame(self) -> Frame {
let mut frame = Frame::array();
frame.push_bulk(Bytes::from("ping".as_bytes()));
if let Some(msg) = self.msg {
frame.push_bulk(Bytes::from(msg));
}
frame
}
}