SIGN IN SIGN UP

macros: crate-wide impl_wire_enum + dedupe infra (typed-status PR 4a) (#569)

* macros: promote impl_wire_enum crate-wide + dedupe encoder/test infra (typed-status sweep PR 4a)

Zero behavior change. Sets up PR 4b (ExecutionFilterSide) and PR 5b
(ExecutionSide) to use the same shape without further infra work.

- Move impl_str_partial_eq! and impl_wire_enum! from contracts/types.rs
  to a new src/macros.rs reachable crate-wide via #[macro_use] mod
  macros; in lib.rs. Project convention had been module-local macros;
  justified by 6-consumer count (OptionRight, SecurityIdType, LegAction
  in contracts/; OrderStatusKind retrofit here + imminent
  ExecutionFilterSide + ExecutionSide in orders/). Orphan rule
  forecloses blanket-impl alternatives (rule 25 case a).

- Promote check_wire_enum_round_trip and check_wire_enum_rejects_unknown
  from contracts/types_tests.rs to a new pub mod wire_enum in
  common/test_utils.rs. Generic helper functions, not a macro (rule 25
  preferred shape). orders/tests.rs and contracts/types_tests.rs both
  consume.

- Add some_display(Option<and impl Display>) returning Option<String>
  next to some_str in proto/encoders.rs and convert the two existing
  PR 2 / PR 3b sites (right, sec_id_type). Third site (PR 4b
  filter.side) hits the rule-of-three tripwire; closes the PR 3b
  /simplify tracked deferral.

- Retrofit OrderStatusKind in orders/mod.rs to as_str + from_wire +
  impl_wire_enum!. Drops the hand-rolled Display + FromStr; gains
  ToField (additive, no removal). Closes the PR 3a follow-up note.

* /simplify pass: merge OrderStatusKind impl blocks to match precedent

Three `impl OrderStatusKind` blocks (as_str+from_wire, then macro
invocation, then is_active+is_terminal) collapse to one inherent block
followed by impl_wire_enum!. Matches the OptionRight / SecurityIdType /
LegAction precedent in contracts/types.rs — single inherent block, then
the macro. Pure code motion, no semantic change.
W
Wil Boayue committed
db3c6059344164be3a64dc2916d3a43bfc3e7e2f
Parent: a1b2e99
Committed by GitHub <noreply@github.com> on 5/12/2026, 10:11:06 PM