Skip to content

Support for fallback enums #81

Description

@valkum

While implementing an extension for instant-epp I would like to parse

<changePoll:caseId name="other" type="custom">urs123</changePoll:caseId>

into the following ergonomic Rust representation

#[derive(Debug, FromXml, ToXml)]
#[xml(rename = "caseId", ns(XMLNS))]
pub struct CaseIdentifier<'a> {
    #[xml(attribute, rename = "type")]
    pub id_type: CaseIdentifierType,
    #[xml(direct)]
    pub id: Cow<'a, str>,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CaseIdentifierType<'a> {
    Udrp,
    Urs,
    Custom(&'a str),
}

It would be nice if CaseIdentifierType can take a #[from_attribute("name")] or similar to generate code that lets CaseIdentifierType consume an attribute node of the parent element node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions