79139428

Date: 2024-10-30 01:45:33
Score: 0.5
Natty:
Report link

I ended up not being able to work it out. I took a compromise where strings could be passed through extensions normally, I converted the enum type to a string, and then converted the string to an enum in mapper_response

#[derive(Debug, Deserialize, Clone, AsRefStr, EnumString)]
#[serde(tag = "type", content = "data")]
pub enum Error {
    LoginFail,

    // Auth error
    AuthFaildNoAuthTokenCookie,
    AuthFaildTokenFormatWrong,
    AuthFaildCtxNotInRequestExt,

    // model errors.
    ListenerCreationFailed(ListenerCreationError),
    ListenerRemoveFailed,
    ListenerEditFailed,
}

mapper_response:

response.extensions_mut().insert(self.as_ref().to_string());
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: hanghang