Skip to content

feat: add Default impls and new() constructors#1211

Merged
roderickvd merged 5 commits into
masterfrom
feat/default-impls
May 19, 2026
Merged

feat: add Default impls and new() constructors#1211
roderickvd merged 5 commits into
masterfrom
feat/default-impls

Conversation

@roderickvd
Copy link
Copy Markdown
Member

@roderickvd roderickvd commented May 19, 2026

As I noticed PipeWire had a curious choice of #[default] Roles, I did a sweep across all hosts to implement Default where it makes sense, add a new() constructor where idiomatic, and check the sanity of existing Default implementations.

These are not defined on the trait, so use it for platform-specific convenience rather than expecting it works cross-platform (it doesn't).

Additionally, tidy up the derives particularly on non-public types in order to reduce compile times.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Default implementations and lightweight new() constructors across several backend-specific types, and standardizes enum defaults where appropriate (including a small behavioral fix in AudioWorklet device enumeration). These changes are platform conveniences (not trait-level guarantees) and primarily improve ergonomics for backend-specific usage.

Changes:

  • Implement Default for core enums (BufferSize, SupportedBufferSize) and multiple backend Host/Device types; add new() constructors where idiomatic.
  • Adjust backend code to construct devices via Device::new() / Device::default() consistently.
  • Fix AudioWorklet Devices::default() to only enumerate when Host::is_available().

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib.rs Adds Default for BufferSize and SupportedBufferSize with explicit default variants.
src/host/webaudio/mod.rs Adds Default for Device/Host, adds Device::new(), and uses it in iteration/default device selection.
src/host/wasapi/mod.rs Adds Default for WASAPI Host.
src/host/pipewire/device.rs Changes Role default to Sink; adds Default for NodeOverrides and introduces NodeOverrides::new().
src/host/null/mod.rs Adds Default for several null-backend types and introduces new() constructors.
src/host/coreaudio/macos/mod.rs Adds Default for CoreAudio (macOS) Host.
src/host/coreaudio/ios/mod.rs Adds Default for iOS CoreAudio Device/Host and adds Device::new().
src/host/coreaudio/ios/enumerate.rs Updates enumeration/default-device construction to use Device::new() / Device::default().
src/host/audioworklet/mod.rs Adds Default for Device/Host, adds Device::new(), and fixes Devices::default() gating on availability.
src/host/asio/stream.rs Derives Default for TimeBase and simplifies TimeBase::new() to delegate to default().
src/host/aaudio/mod.rs Adds Default for Host/Device, adds Device::new(), and updates fallback/default device creation.
src/host/aaudio/java_interface/definitions.rs Adds Default to AudioDeviceType with Unknown as the default variant.
CHANGELOG.md Documents the newly added Default/new() conveniences and the AudioWorklet enumeration fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/host/pipewire/device.rs Outdated
Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comment thread src/host/audioworklet/mod.rs
@roderickvd roderickvd merged commit 73d6468 into master May 19, 2026
32 checks passed
@roderickvd roderickvd deleted the feat/default-impls branch May 19, 2026 21:43
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