Files
wz-phone/docs/PRD/reports/T1.2-report.md
2026-05-11 11:09:43 +04:00

3.1 KiB

T1.2 — Add MediaType enum

Status: Pending Review Agent: Kimi Code CLI Started: 2026-05-11T06:55Z Completed: 2026-05-11T07:08Z Commit: see git log PRD: ../PRD-wire-format-v2.md

What I changed

  • crates/wzp-proto/src/media_type.rs:1-55 — created new module with MediaType enum (Audio=0, Video=1, Data=2, Control=3), to_wire(), from_wire(), and two unit tests
  • crates/wzp-proto/src/lib.rs:18 — added pub mod media_type;
  • crates/wzp-proto/src/lib.rs:28 — added pub use media_type::MediaType;
  • crates/wzp-proto/src/packet.rs:4 — added use crate::MediaType;
  • crates/wzp-proto/src/packet.rs:168 — changed MediaHeaderV2.media_type from u8 to MediaType, resolving the TODO(T1.2)
  • crates/wzp-proto/src/packet.rs:184write_to now calls self.media_type.to_wire()
  • crates/wzp-proto/src/packet.rs:202read_from now uses MediaType::from_wire(buf.get_u8())?
  • crates/wzp-proto/src/packet.rs:1292 — updated media_header_v2_roundtrip test to use MediaType::Audio

Why these choices

Followed steps T1.2.1 through T1.2.2 without deviation. Since MediaType now exists, I also resolved the TODO(T1.2) placeholder left in MediaHeaderV2 during T1.1 so the v2 header is internally consistent before moving on.

Deviations from the task spec

None.

Verification output

$ cargo test -p wzp-proto media_type
running 2 tests
test media_type::tests::media_type_roundtrip ... ok
test media_type::tests::media_type_unknown_rejected ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 106 filtered out; finished in 0.00s
$ cargo test -p wzp-proto media_header_v2_roundtrip
running 1 test
test packet::tests::media_header_v2_roundtrip ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 107 filtered out; finished in 0.00s
$ cargo build -p wzp-proto -p wzp-codec -p wzp-fec -p wzp-crypto -p wzp-transport -p wzp-relay -p wzp-client -p wzp-web -p wzp-native
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 15.31s
$ cargo test -p wzp-proto -p wzp-codec -p wzp-fec -p wzp-crypto -p wzp-transport -p wzp-relay -p wzp-client -p wzp-web -p wzp-native --no-fail-fast
...
test result: ok. 567 passed; 0 failed; ...
$ cargo clippy -p wzp-proto --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s
$ cargo fmt --all -- --check
# (clean)

Test summary

  • Tests added: 2 (media_type_roundtrip, media_type_unknown_rejected)
  • Tests modified: 1 (media_header_v2_roundtrip — now uses MediaType::Audio)
  • Workspace test count before: 565 pass / 0 fail (non-Android subset)
  • Workspace test count after: 567 pass / 0 fail (non-Android subset)
  • cargo clippy -p wzp-proto --all-targets -- -D warnings: pass
  • cargo fmt --all -- --check: pass

Risks / follow-ups

None.

Reviewer checklist (filled in by reviewer)

  • Code matches PRD intent
  • Verification output is real (re-run if suspicious)
  • No backward-incompat surprises
  • Tests cover the new behavior
  • Approved