Skip to main content

Module serialization

Module serialization 

Source
Expand description

JSON serialization for face records and face matches.

Face records export directed lb/ub corners (raw il/jl/kl and ih/jh/kh). After face_matches_to_dict, these corners are physically corresponding: block1’s lb matches block2’s lb in xyz space, and block1’s ub matches block2’s ub.

The permutation_index (0-7) indicates which PERMUTATION_MATRICES entry transforms face B’s ascending canonical grid to match face A’s. It is included as metadata; the directed corners already encode the corner-to-corner mapping.

{
  "block1": { "block_index": 0, "lb": [0,0,0], "ub": [24,408,0] },
  "block2": { "block_index": 1, "lb": [408,0,0], "ub": [0,0,24] },
  "permutation_index": 5
}

§Round-tripping

The write side (face_record_to_json, face_match_to_json) and the read side (face_record_from_json, face_match_from_json) form a round-trip pair for the directed-corner JSON format shown above. Because the struct field layout in FaceRecord (il/jl/kl, ih/jh/kh) does not match the nested lb/ub array format that downstream tooling emits, a plain #[derive(Deserialize)] is not sufficient: we parse manually to honour the directed-corner contract.

Functions§

face_match_from_json
Parse a FaceMatch from its directed-corner JSON representation.
face_match_to_json
Convert a FaceMatch to JSON with directed lb/ub corners.
face_record_from_json
Parse a FaceRecord from its directed-corner JSON representation.
face_record_to_json
Convert a FaceRecord to JSON with directed lb/ub corners.
permutation_matrices_json
Serialize the 8 permutation matrices as a JSON array (for inclusion in output headers).