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