Repository navigation
feat(core): a Rust API that can grow - #154
Merged
Merged
Conversation
The Rust half of #152 (D70), on top of the C half: - #[non_exhaustive] on the enums that grow (the errors, the header kinds, TexturePicture, TimedOutput, ColorMatrix, RgbOrder) and on the structs: the timings and frames callers read, and GpuOptions, ColorParams and Signalling, which callers make from their Default. ColorParams::new takes its three members; Timings has a Default. - The decoder's calls that record into the caller's encoder are record_rgb, record_rgb_to_texture and record_to_plane_textures, apart from the encoders' encode_rgb. - GpuOptions::default() no longer reads EMBERWAVE_BACKEND; from_env() does, for the CLI and the C API's NULL options. - set_partial_share returns a Result and refuses a share outside 0 to 1, or NaN, with the new GpuError::InvalidArgument, as the C API and the browser player did; it clamped before. - pwv1::HEADER_BYTES is FILE_HEADER_BYTES, apart from a frame header's. - Items for emberwave's own tests are hidden from the docs, which say they are not part of the API. - The calls that wait for the GPU are not built for wasm32. - emberwave_core::wgpu re-exports the wgpu emberwave is built with. BREAKING CHANGE: Rust callers add wildcard arms, build those structs from their Default, and use the record_* names. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42
The C half's review fixes, under the Rust half. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42
The review found no defect of weight in the API change itself: the rewritten struct literals keep their values, nothing blocking is built for wasm32, and the wildcard arms are unreachable today. It found what follows: - The tests no longer took EMBERWAVE_BACKEND, which CLAUDE.md and CONTRIBUTING.md promise for forcing a backend, once Default stopped reading it. They start from GpuOptions::from_env() again, through tests/common's options() and in the unit and C API tests, so that one run uses one backend. - A matrix the C API has no constant for would have reached C callers as BT.709 through a wildcard. stream_info now fails as a bug of emberwave's instead, and keeps BT.709's arm explicit. - Docs: from_env's doc still compared it with Default; three links pointed at hidden items; Concealer::bands showed a hidden type; the browser's docs linked to calls its build leaves out, which the crate now allows on wasm32 only; D59's share rule and D60's encode_rgb are marked superseded; draw.wgsl named the old call. The CHANGELOG says which structs other crates read and no longer make. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The Rust half of #152: an
emberwave-coreAPI that can grow without breaking callers, before 1.0 freezes it (D70). It builds on #153, the C half, merged before it.Changes
#[non_exhaustive]on the enums that grow:GpuError,EncodeError,ColorError,bitstream::Error,bitstream::Header,TexturePicture,TimedOutput,ColorMatrixandRgbOrder.The same on the structs that grow:
GpuOptions,ColorParamsandSignalling, which callers make fromDefaultand change member by member.ColorParams::newtakes its three members, andTimingsderivesDefault.Names.
Decoder::record_rgb,record_rgb_to_textureandrecord_to_plane_texturesreplaceencode_*, which the encoders'encode_rgboverlapped.Options.
GpuOptions::default()no longer reads the environment;from_env()does, for the CLI and the C API'sNULLoptions.The share.
Decoder::set_partial_sharereturns aResult, with a newGpuError::InvalidArgumentfor a share outside 0 to 1 or NaN, as the C API and the browser player refuse it. The C API and the player now take the decoder's error.One constant name.
pwv1::HEADER_BYTESisFILE_HEADER_BYTES.Internal items. Those there for tests and tools are
#[doc(hidden)], and the crate's docs say they are outside the API.The browser build. Calls that wait for the GPU are not built for wasm32. The GPU module allows unused helpers there only.
wgpu.pub use wgpu, so that callers take the version emberwave is built with.Docs and callers.
ARCHITECTURE.md, andCHANGELOG.md.record_rgb_to_texture.Testing
cargo test --release --workspaceon the M3 Max. The partial share test now checks that out-of-range shares are refused and leave the share.cargo fmt --check; clippy with-D warningsfor the workspace, for--no-default-features, for wasm32 (emberwave-webandemberwave-core), and forx86_64-pc-windows-msvc --workspace --all-targets.RUSTDOCFLAGS=-D warnings cargo docfor the core and the C API.Benchmark impact
None.
Review
Our review agent compared every rewritten literal with the original, traced every blocking call on wasm32, and built the browser player for wasm32. It ran the tests in release and debug, the Rust 1.87 check, and clippy for Windows and wasm32. It found no defect of weight in the API change. Its findings are fixed in 357cf92:
EMBERWAVE_BACKENDonceDefaultstopped reading it, though CLAUDE.md and CONTRIBUTING.md promise it for forcing a backend. They start fromGpuOptions::from_env()again, so that one run uses one backend.from_env's doc was stale, three doc links pointed at hidden items, andConcealer::bandsshowed a hidden type.draw.wgslnamed the old call.mainhas since merged #153, which this branch includes.Related issue
Closes #152 together with #153.