Skip to main content

split_v1

Function split_v1 

Source
pub fn split_v1(body: &Value) -> SplitV1
Expand description

Split an evalhub.eval/1.0 body into a 2.0 header and its runs.

Pure: no I/O, the input is not modified, and the same body always gives the same result. The mapping is in the module doc. Duplicate run_ids do not fail the call: the last element with an id wins, and the ids are listed in SplitV1::duplicate_run_ids.

Meant for a body crate::validate::validate accepted as 1.0. On anything else it still returns, without guessing more than it must: a body that is not an object is returned as the header with no runs; a runs[] element without a string run_id is dropped; an outcome other than the four 1.0 values is treated as error (unrecorded), and kept verbatim in meta like any other.

Cost: one clone of the body plus one pass over runs[] and the header’s attachments[] per run.