Skip to main content

split

Function split 

Source
pub fn split(d: &Descriptor) -> Result<Vec<String>, Error>
Expand description

Split a Descriptor into N codex32 md1 strings, each carrying a chunk header and a slice of the canonical payload.

Algorithm:

  1. Encode the full payload (encode_payload).
  2. Compute crate::identity::Md1EncodingId; derive ChunkSetId.
  3. Choose chunk count N such that each chunk fits in codex32 long form after adding the 37-bit chunk header.
  4. Split the payload into N approximately-equal byte-boundary slices.
  5. For each chunk i: prepend chunk header (37 bits), wrap via codex32 with the chunked-flag bit set, emit md1 string.

Note: bytes_per_chunk could be 0 if payload_bytes were empty, but the encoder validates n ≥ 1 so the payload is always non-empty.