с кодом:
                  
                  
                  use mini_redis::{client, Result};
                  
                  
                  
                  
                  
                  #[tokio::main]
                  
                  
                  async fn main() -> Result<()> {
                  
                  
                      let mut client = client::connect("127.0.0.1:6379").await?;
                  
                  
                  
                  
                  
                      client.set("hello", "world".into()).await.unwrap();
                  
                  
                      let result = client.get("hello").await?;
                  
                  
                      println!("got value from the server; result={:?}", result);
                  
                  
                      
                  
                  
                      Ok(())
                  
                  
                  }
                  
                  
                  Сервер как и в примере возвращает 
                  
                  
                  Frame::Simple("Ok".to_string())
                  
                  
                  . Клиент паникует на строчке 
                  
                  
                  client.set("hello", "world".into()).await.unwrap();
                  
                  
                   с ошибкой 
                  
                  
                  unexpected frame: Ok
                  
                  
                  Код сервера:
                  
                  
                  use tokio::net::TcpStream;
                  
                  
                  use mini_redis::{Connection, Frame};
                  
                  
                  
                  
                  
                  async fn process(socket: TcpStream) {
                  
                  
                      use mini_redis::Command::{self, Get, Set};
                  
                  
                      use std::collections::HashMap;
                  
                  
                  
                  
                  
                      // A hashmap is used to store data
                  
                  
                      let mut db = HashMap::new();
                  
                  
                  
                  
                  
                      // Connection, provided by `mini-redis`, handles parsing frames from
                  
                  
                      // the socket
                  
                  
                      let mut connection = Connection::new(socket);
                  
                  
                  
                  
                  
                      // Use `read_frame` to receive a command from the connection.
                  
                  
                      while let Some(frame) = connection.read_frame().await.unwrap() {
                  
                  
                          let response = match Command::from_frame(frame).unwrap() {
                  
                  
                              Set(cmd) => {
                  
                  
                                  // The value is stored as `Vec<u8>`
                  
                  
                                  db.insert(cmd.key().to_string(), cmd.value().to_vec());
                  
                  
                                  Frame::Simple("OK".to_string())
                  
                  
                              }
                  
                  
                              Get(cmd) => {
                  
                  
                                  if let Some(value) = db.get(cmd.key()) {
                  
                  
                                      // `Frame::Bulk` expects data to be of type `Bytes`. This
                  
                  
                                      // type will be covered later in the tutorial. For now,
                  
                  
                                      // `&Vec<u8>` is converted to `Bytes` using `into()`.
                  
                  
                                      Frame::Bulk(value.clone().into())
                  
                  
                                  } else {
                  
                  
                                      Frame::Null
                  
                  
                                  }
                  
                  
                              }
                  
                  
                              cmd => panic!("unimplemented {:?}", cmd),
                  
                  
                          };
                  
                  
                          connection.write_frame(&response).await.unwrap();
                  
                  
                      }
                  
                  
                  }
                  
                  
                
Короче перерыл исходники mini_redis прочитал спецификацию протокола, и понял что сделал ошибку: надо было возвращать OK большими буквами, а не Ok
Обсуждают сегодня