Skip to main content

restructure_groups

Function restructure_groups 

Source
pub fn restructure_groups(
    map: &mut FieldMap,
    spec: &dyn GroupSpec,
) -> Result<(), DecodeError>
Expand description

Re-group an already-decoded, flat FieldMap against spec — the in-memory counterpart to decode_with_groups’s wire-level grouping (feature 011, FR-008). Needed because a FIXT 1.1 application dictionary is only resolvable after this crate’s decode step already ran (its selection depends on session state — the negotiated ApplVerID — that this crate has no visibility into; see truefix-session’s post-decode restructuring call site): map is first flattened back to a plain token stream (recursively, so a Member::Group entry from some other already-applied spec is flattened too, not left half-structured) and then re-grouped via [decode_section_with_groups] — the exact same boundary-detection algorithm decode_with_groups itself uses, so the two paths can never diverge (Constitution Principle IV). A tag spec doesn’t recognize as a group ends up a plain field, exactly like decode_with_groups. Calling this on an already-correctly-structured map (relative to spec) is a safe, idempotent no-op (flattening then immediately re-grouping the same content the same way).