impl<'a, T> Serialize for Request<'a, T>
where
T: Serialize
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer
{
let mut tup = serializer.serialize_tuple(3)?;
tup.serialize_element("commandName")?;
tup.serialize_element(&self.req)?;
tup.serialize_element(self.tag)?;
tup.end()
}
}
The Problem is that I cannot get commandName from self.req.
I might be able not to use a struct CommandName, but an enum encompassing all possible commands, but that will make it harder in other parts of the code.
Any idea? I would prefer not having to use proc macros.
I would really like to avoid having to hard code commandName. It should come from the struct's name CommandName. Is that possible without too much effort?