Skip to content

fix: support all accumulators in enum forward deserialization #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

gibbz00
Copy link
Contributor

@gibbz00 gibbz00 commented Oct 22, 2024

Previously limited to Option only.

The following does not compile in main:

#[derive(Debug, PartialEq, ToXml, FromXml)]
#[xml(forward)]
enum FooCow<'a> {
    Bar(Cow<'a, [BarBorrowed<'a>]>),
    Baz(Cow<'a, [BazBorrowed<'a>]>),
}

Copy link
Owner

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work figuring this out, this crate isn't exactly well-documented...

Can you explain at a conceptual level why you want/need this?

@djc
Copy link
Owner

djc commented Oct 22, 2024

Fixing the pre-existing clippy issue in #72.

@gibbz00 gibbz00 force-pushed the forward_non_option branch from 6d69830 to 42280d0 Compare October 22, 2024 19:56
@gibbz00
Copy link
Contributor Author

gibbz00 commented Oct 22, 2024

Nice work figuring this out, this crate isn't exactly well-documented...

Thanks! Yeah, at this stage it will have to be a dedicated effort for it to happen. Not a big deal right now since those looking at this crate in the first place will probably have a fairly good understanding of serde, which helps.

Can you explain at a conceptual level why you want/need this?

Sure! My task at work is to add support for secDNS per RFC 5910. (djc/instant-epp#17). The <info> part returns the same DsOrKeyData enum currently used by <create>. It could be reused with a slight semver bump if:

#[derive(Debug, ToXml)]
#[xml(forward)]
pub enum DsOrKeyData<'a> {
    DsData(&'a [DsDataType<'a>]),
    KeyData(&'a [KeyDataType<'a>]),
}

// is turned into this:

#[derive(Debug, ToXml, FromXml)]
#[xml(forward)]
pub enum DsOrKeyData<'a> {
    DsData(Cow<'a, [DsDataType<'a>]>),
    KeyData(Cow<'a, [KeyDataType<'a>]>),
}

@gibbz00 gibbz00 force-pushed the forward_non_option branch 2 times, most recently from 67720f6 to 1bff427 Compare October 22, 2024 20:46
@gibbz00 gibbz00 force-pushed the forward_non_option branch from 1bff427 to 4bb892f Compare October 22, 2024 20:51
@gibbz00 gibbz00 force-pushed the forward_non_option branch from 4bb892f to cda5bc4 Compare October 22, 2024 20:57
@djc djc merged commit 1bae618 into djc:main Oct 22, 2024
7 checks passed
@gibbz00 gibbz00 deleted the forward_non_option branch October 22, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants