Skip to content

hang: non_exhaustive VideoConfig/AudioConfig with constructors#1485

Merged
kixelated merged 1 commit into
mainfrom
claude/funny-mccarthy-923790
May 24, 2026
Merged

hang: non_exhaustive VideoConfig/AudioConfig with constructors#1485
kixelated merged 1 commit into
mainfrom
claude/funny-mccarthy-923790

Conversation

@kixelated
Copy link
Copy Markdown
Collaborator

Summary

  • Mark hang::catalog::VideoConfig and AudioConfig as #[non_exhaustive] so additional optional fields can be added without bumping the major version.
  • Add VideoConfig::new(codec) and AudioConfig::new(codec, sample_rate, channel_count) constructors that clear every optional field and default container via Container::default(). Callers assign whichever optional fields they need afterwards.
  • Migrate every in-tree struct-literal site (15 files) across hang and moq-mux to the new constructors.

Why

Without #[non_exhaustive], every additive field on these public structs is a SemVer-breaking change for downstream Rust users that construct via struct literals. The previous attempt to add #[non_exhaustive] was rolled back because moq-mux (a separate crate) could no longer build via struct literals; the new(...) constructors are the unblocker.

This follows the pattern established in 9f780fa ("Tighten public APIs ahead of release: non_exhaustive + builders") for AuthToken and moq_msf::Track.

Notes for reviewers

  • Required fields per constructor: VideoConfig::new only takes codec (everything else is optional or has Default); AudioConfig::new takes codec, sample_rate, and channel_count since the latter two have no sensible default and a wrong value silently distorts playback.
  • Both constructors accept impl Into<{Video,Audio}Codec>, so callers can pass an H264 { ... } (or other variant payload) directly without .into().
  • I touched a few sites beyond the original task list — additional struct-literal sites in rs/moq-mux/src/container/mkv/{import,export_test}.rs and several test cases in rs/moq-mux/src/catalog/hang/producer.rs — because they would otherwise fail to compile against the #[non_exhaustive] types.

Test plan

  • just check (rustc, clippy -D warnings, fmt, cargo doc, cargo sort, biome, remark)
  • just rs test — all suites pass, including the catalog roundtrip tests in hang and the hang/msf catalog tests in moq-mux

🤖 Generated with Claude Code

Mark both catalog config structs as `#[non_exhaustive]` so future optional
fields (e.g. a `broadcast: Option<PathRelativeOwned>`) can be added without
a major bump. External callers now build configs via `VideoConfig::new(codec)`
and `AudioConfig::new(codec, sample_rate, channel_count)`, then assign the
optional fields they care about.

Follows the pattern from 9f780fa (`AuthToken`, `moq_msf::Track`). Migrates
every in-tree struct-literal site across `hang` and `moq-mux`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2f47c0a-51fc-4da0-8ed7-0c59d4caafb3

📥 Commits

Reviewing files that changed from the base of the PR and between aacba0d and d030251.

📒 Files selected for processing (15)
  • rs/hang/examples/video.rs
  • rs/hang/src/catalog/audio/mod.rs
  • rs/hang/src/catalog/root.rs
  • rs/hang/src/catalog/video/mod.rs
  • rs/moq-mux/src/catalog/hang/producer.rs
  • rs/moq-mux/src/catalog/msf/consumer.rs
  • rs/moq-mux/src/codec/aac/import.rs
  • rs/moq-mux/src/codec/av1/import.rs
  • rs/moq-mux/src/codec/h264/import.rs
  • rs/moq-mux/src/codec/h265/import.rs
  • rs/moq-mux/src/codec/opus/import.rs
  • rs/moq-mux/src/container/fmp4/export_test.rs
  • rs/moq-mux/src/container/fmp4/import.rs
  • rs/moq-mux/src/container/mkv/export_test.rs
  • rs/moq-mux/src/container/mkv/import.rs

Walkthrough

This PR introduces public constructors for VideoConfig and AudioConfig and marks both structs #[non_exhaustive] to enforce constructor-based initialization. The VideoConfig::new() takes a codec and returns a config with all optional fields set to defaults, while AudioConfig::new() additionally accepts sample rate and channel count as required parameters. Every construction site across codec importers, container handlers, and tests is refactored from verbose struct literals to this new two-step pattern: initialize via the constructor, then set codec-specific or test-specific fields.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: marking VideoConfig and AudioConfig as non_exhaustive while adding constructors.
Description check ✅ Passed The description clearly explains the purpose, implementation, and rationale for the changes with specific details about the constructors and migration.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/funny-mccarthy-923790
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/funny-mccarthy-923790

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kixelated kixelated enabled auto-merge (squash) May 24, 2026 18:06
@kixelated kixelated merged commit 0df27a9 into main May 24, 2026
1 check passed
@kixelated kixelated deleted the claude/funny-mccarthy-923790 branch May 24, 2026 18:06
kixelated added a commit that referenced this pull request May 24, 2026
Origin/main (#1485) marked VideoConfig and AudioConfig #[non_exhaustive]
and added `::new()` constructors that the existing in-tree call sites
now use. Resolved by taking main's version of every moq-mux import site
and the hang/examples/video.rs example (they use the new constructor
pattern) and re-adding the optional `broadcast` field to the structs +
constructors. The catalog tests in root.rs likewise switch to the
builder style.

Written by Claude

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@moq-bot moq-bot Bot mentioned this pull request May 24, 2026
kixelated added a commit that referenced this pull request May 24, 2026
Main landed #1485 (`hang: non_exhaustive VideoConfig/AudioConfig with
constructors`) while this PR was open. The struct-literal calls in
`moq-audio` and `moq-ffi` are no longer allowed; switch to
`AudioConfig::new(codec, sample_rate, channel_count)` and assign the
optional `bitrate` / `description` / `container` fields afterward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
kixelated added a commit that referenced this pull request May 24, 2026
Main landed #1485 (`hang: non_exhaustive VideoConfig/AudioConfig with
constructors`) while this PR was open. The struct-literal calls in
`moq-audio` and `moq-ffi` are no longer allowed; switch to
`AudioConfig::new(codec, sample_rate, channel_count)` and assign the
optional `bitrate` / `description` / `container` fields afterward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@moq-bot moq-bot Bot mentioned this pull request May 24, 2026
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.

1 participant