using serde and tealr in the same derive
Closed this issue · 7 comments
Hello, I'm trying here to use enum from lua and this enum values would be formatted in json from the rust program but the main problem here is I cannot use the serde to convert the enum to json or using tealr to make it usable from lua side at the same time
use tealr::{mlu::FromToLua, TypeName};
use serde::{Deserialize, Serialize};
#[derive(Clone,FromToLua, TypeName ,Deserialize, Serialize)]
#[serde(untagged)]
#[tealr(creator_name = MatcherCreator)]
pub enum ReportMatchers {
RawRequest(String),
RawResponse(String),
RequestHeaders(String),
ResponseHeaders(String),
ResponseBody(String),
RequestBody(String),
}
What is the error that you get?
Edit: Tealr itself uses this a few times itself now. So, as far as I am aware it should just work? I also can't think of any traits that would overlap.
Hey @lenscas , I got this error when I tried to compile it
error: cannot find attribute `serde` in this scope
--> src/lua/output/cve.rs:25:3
|
25 | #[serde(untagged)]
| ^^^^^
|
= note: `serde` is in scope, but it is a crate, not an attribute
Oh. Weird. Guess I am not handling tags from other crates properly, i would need to look into that.
However in this case I don't even get how this enim can be untagged as they all only contain strings. I have the feeling that this won't do what you want even if I would handle the tag correctly
The bug is caused by https://github.com/lenscas/tealr/blob/master/tealr_derive/src/from_to_lua.rs#L453
It should filter out attributes that aren't supported.
I am going to close this and assume it is fixed. Feel free to reopen if it is not