mini_redis/cmd/
unknown.rs1use crate::{Connection, Frame};
2
3use tracing::{debug, instrument};
4
5#[derive(Debug)]
7pub struct Unknown {
8 command_name: String,
9}
10
11impl Unknown {
12 pub(crate) fn new(key: impl ToString) -> Unknown {
15 Unknown {
16 command_name: key.to_string(),
17 }
18 }
19
20 pub(crate) fn get_name(&self) -> &str {
22 &self.command_name
23 }
24
25 #[instrument(skip(self, dst))]
29 pub(crate) async fn apply(self, dst: &mut Connection) -> crate::Result<()> {
30 let response = Frame::Error(format!("ERR unknown command '{}'", self.command_name));
31
32 debug!(?response);
33
34 dst.write_frame(&response).await?;
35 Ok(())
36 }
37}