package catalogue import ( "encoding/json" "strings" ) // Decode reads a manifest leniently, as every part but the judge reads one (novox/hq ADR 0578 §3): every field the // contract knows as it declares it, and a field it does not know set aside and named (SetAside), never refused. It // judges nothing: no name, seat, bus or catalogue rule is applied, since the indexer judged the manifest once and its // verdict is in the indexer's state (delivery.VerdictsBucket); a reader takes the verdict beside it // (delivery.TakeVerdict). An error is only bytes that are no manifest: not JSON, or a field of the wrong shape. func Decode(raw []byte) (Manifest, error) { var m Manifest if err := json.Unmarshal(raw, &m); err != nil { return Manifest{}, err } return m, nil } // SetAside names what Decode set aside of this manifest: each field it does not know, as the decoder words the first // and with the path of every one it read without, or "" when it knew every field. A reader says it in its own words // (its journal, its finding) and reads the rest; the part that needs the field takes the newer package (ADR 0578 §6). func (m Manifest) SetAside() string { return m.unknown } // ReadNoFurther is whether Decode could not read past a field it does not know, so the manifest holds its name and // version alone: a reader holds such a module, as it holds a refused one, and names why (SetAside). func (m Manifest) ReadNoFurther() bool { return strings.Contains(m.unknown, readNoFurther) } // readNoFurther marks, in what a manifest set aside, that it was not read past it. const readNoFurther = "(read no further: "