Skip to main content

encode_member

Function encode_member 

Source
pub fn encode_member(
    member_json: &[u8],
    entries: &[ManifestEntry],
    sidecar_texts: &HashMap<String, String>,
) -> Result<Vec<u8>, CoreError>
Expand description

Encode one member’s scripts back: re-resolve each manifest pointer to its raw byte span in the CURRENT member bytes (the same shared scanner — re-scanning at encode time keeps splices valid even when the user hand-edited the member JSON), then splice the re-encoded replacement (reindent + flint_encode) at that span. Rules:

  • a manifest entry whose sidecar is ABSENT from sidecar_texts keeps the JSON’s current value (never silently drop edits);
  • a pointer that no longer resolves keeps the current value;
  • unedited members re-encode BYTE-IDENTICAL (the sacred invariant at file level — untouched spans copy verbatim).