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 · 1 comment
Open

Mark AudioDecoderOptions as #[non_exhaustive] #335

caass opened this issue Jan 2, 2025 · 1 comment

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

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

1 participant