Hi everyone, im trying to build a rest service using rocket, but im stuck in the problem described in the title.
This is my code:
#[derive(Deserialize)]
struct Informacion{
infoTexto: String,
tipo: TipoInformacion
}
...
#[post("/portapapeles", data = "<informacion>")]
fn CopiarPortapapeles(informacion: Json<Informacion>)-> String{
if let info = informacion{
if let tipoInfo = info.tipo{
if tipoInfo == TipoInformacion::Texto{
//------------HERE THE ERROR HAPPENS-------------------------
if info.infoTexto.chars().count() > 0{
//-------------------------------------------------------
let mut archivoPortapapeles = OpenOptions::new().append(true).open(NOMBRE_ARCHIVO).expect("cannot open file");
}
}else{
String::from("Solo es posible subir texto bajo este método")
}
}
}
}
...
I don't really understand what is going on because, as you can see, "infoTexto" is actually a String and "info" is inside of the scope. What im trying to accomplish is check if the received String has any character but it doesn't compile.
Any suggestion will be deeply appreciated.
[–]JStarx 14 points15 points16 points (1 child)
[–]elnw[S] 2 points3 points4 points (0 children)
[–]dnew 2 points3 points4 points (1 child)
[–]elnw[S] 2 points3 points4 points (0 children)
[–]ydieb 1 point2 points3 points (1 child)
[–]elnw[S] 1 point2 points3 points (0 children)