Hi everybody. I'm trying to have it so that my server can properly respond to post requests from the client. I'm getting "Cannot move out of dereference of" Errors at info.key, info.field, and info.value. How do I go about fixing this? Code would be appreciated!
mod database;
use actix_files as fs;
use actix_web::{App, HttpResponse, HttpServer, Responder, web};
use serde::Deserialize;
#[derive(Deserialize)]
struct Info
{
operation: String,
key: String,
field: String,
value: String
}
async fn index(info: web::Json<Info>) -> impl Responder
{
if info.operation == "set".to_string()
{
database::set(info.key, info.value).ok();
HttpResponse::Ok().body("Success!")
}
else if info.operation == "get".to_string()
{
let data = (database::get(info.key).ok()).unwrap();
HttpResponse::Ok().body(data)
}
else if info.operation == "hset".to_string()
{
database::hset(info.key, info.field, info.value).ok();
HttpResponse::Ok().body("Success!")
}
else if info.operation == "hget".to_string()
{
let data = database::hget(info.key, info.field).ok().unwrap();
HttpResponse::Ok().body(data)
}
else
{
HttpResponse::Ok().body("Unknown Operation")
}
}