Skip to content
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

Mark AudioDecoderOptions as #[non_exhaustive] #335

Open
caass opened this issue Jan 2, 2025 · 2 comments
Open

Mark AudioDecoderOptions as #[non_exhaustive] #335

caass opened this issue Jan 2, 2025 · 2 comments
Milestone

Comments

@caass
Copy link

caass commented Jan 2, 2025

I saw in symphonia-play that clippy::needless_update is allowed because the fields of AudioDecoderOptions may change, but that shouldn't require a code change to symphonia-play. The intended mechanism for this is to use the #[non_exhaustive] marker on AudioDecoderOptions, but that requires more code since non_exhaustive structs can't be updated with a spread pattern.

The "right" way to do this would be to create some sort of builder, either by hand or with something like bon, so that downstream users would call AudioDecoderOptions::builder().verify(bool).build(). i.e.:

// symphonia-core/src/codecs/audio.rs

use bon::Builder;

/// `AudioDecoderOptions` is a common set of options that all audio decoders use.
#[derive(Copy, Clone, Debug, Default, Builder)]
#[non_exhaustive]
pub struct AudioDecoderOptions {
    /// The decoded audio should be verified if possible during the decode process.
    #[builder(default)]
    pub verify: bool,
}
@caass
Copy link
Author

caass commented Jan 3, 2025

This same lint exists in symphonia-check for DecoderOptions and FormatOptions

@pdeljanov pdeljanov added this to the v0.6.0 milestone Feb 16, 2025
@pdeljanov
Copy link
Owner

Thanks for the report.

There are a few other cases which I've been hesitating tagging with #[non_exhaustive] for similar reasons. This will need to be fixed for 0.6 of course. Bon looks really great, though, so far I've preferred to roll my own builders to keep things simple and keep the build times as short as possible.

Tagging with the 0.6 milestone to make sure this gets fixed.

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

No branches or pull requests

2 participants