git.delta.rocks / jrsonnet / refs/commits / 0ad724252f64

difftreelog

refactor replace serde-yaml with serde-saphyr for yaml parsing

oxsqnpvmYaroslav Bolyukin2026-02-07parent: #8a3d104.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
2# It is not intended for manual editing.2# It is not intended for manual editing.
3version = 43version = 4
4
5[[package]]
6name = "ahash"
7version = "0.8.12"
8source = "registry+https://github.com/rust-lang/crates.io-index"
9checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
10dependencies = [
11 "cfg-if",
12 "getrandom",
13 "once_cell",
14 "version_check",
15 "zerocopy",
16]
417
5[[package]]18[[package]]
6name = "aho-corasick"19name = "aho-corasick"
109 "object",122 "object",
110]123]
124
125[[package]]
126name = "arraydeque"
127version = "0.5.1"
128source = "registry+https://github.com/rust-lang/crates.io-index"
129checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
111130
112[[package]]131[[package]]
113name = "autocfg"132name = "autocfg"
302source = "registry+https://github.com/rust-lang/crates.io-index"321source = "registry+https://github.com/rust-lang/crates.io-index"
303checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"322checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
323
324[[package]]
325name = "encoding_rs"
326version = "0.8.35"
327source = "registry+https://github.com/rust-lang/crates.io-index"
328checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
329dependencies = [
330 "cfg-if",
331]
332
333[[package]]
334name = "encoding_rs_io"
335version = "0.1.7"
336source = "registry+https://github.com/rust-lang/crates.io-index"
337checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83"
338dependencies = [
339 "encoding_rs",
340]
304341
305[[package]]342[[package]]
306name = "equivalent"343name = "equivalent"
376checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"413checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
377dependencies = [414dependencies = [
378 "cfg-if",415 "cfg-if",
416 "js-sys",
379 "libc",417 "libc",
380 "r-efi",418 "r-efi",
381 "wasip2",419 "wasip2",
420 "wasm-bindgen",
382]421]
383422
384[[package]]423[[package]]
434 "rand",473 "rand",
435 "random_color",474 "random_color",
436 "range-map",475 "range-map",
437 "smallvec",476 "smallvec 1.15.1",
438 "tree-sitter-highlight",477 "tree-sitter-highlight",
439 "unicode-box-drawing",478 "unicode-box-drawing",
440]479]
641 "regex",680 "regex",
642 "rustc-hash 2.1.1",681 "rustc-hash 2.1.1",
643 "serde",682 "serde",
683 "serde-saphyr",
644 "serde_json",684 "serde_json",
645 "serde_yaml_with_quirks",
646 "sha1",685 "sha1",
647 "sha2",686 "sha2",
648 "sha3",687 "sha3",
656 "peg",695 "peg",
657]696]
697
698[[package]]
699name = "js-sys"
700version = "0.3.85"
701source = "registry+https://github.com/rust-lang/crates.io-index"
702checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3"
703dependencies = [
704 "once_cell",
705 "wasm-bindgen",
706]
658707
659[[package]]708[[package]]
660name = "json-structural-diff"709name = "json-structural-diff"
771 "mimalloc-sys",820 "mimalloc-sys",
772]821]
822
823[[package]]
824name = "nohash-hasher"
825version = "0.2.0"
826source = "registry+https://github.com/rust-lang/crates.io-index"
827checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
773828
774[[package]]829[[package]]
775name = "num-bigint"830name = "num-bigint"
1054checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"1109checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
10551110
1056[[package]]1111[[package]]
1057name = "ryu"1112name = "saphyr-parser-bw"
1058version = "1.0.22"1113version = "0.0.607"
1059source = "registry+https://github.com/rust-lang/crates.io-index"1114source = "registry+https://github.com/rust-lang/crates.io-index"
1060checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984"1115checksum = "2f9bae8d059bf1ca32753cf3cdafbf5d391502de2fc2ca54510811fe9c100d90"
1116dependencies = [
1117 "arraydeque",
1118 "smallvec 2.0.0-alpha.12",
1119 "thiserror",
1120]
10611121
1062[[package]]1122[[package]]
1063name = "serde"1123name = "serde"
1069 "serde_derive",1129 "serde_derive",
1070]1130]
1131
1132[[package]]
1133name = "serde-saphyr"
1134version = "0.0.17"
1135source = "registry+https://github.com/rust-lang/crates.io-index"
1136checksum = "bc14a55107113a16346915d7e3d78acc539a923458385db89670e22cac106d7a"
1137dependencies = [
1138 "ahash",
1139 "annotate-snippets",
1140 "base64",
1141 "encoding_rs_io",
1142 "getrandom",
1143 "nohash-hasher",
1144 "num-traits",
1145 "regex",
1146 "saphyr-parser-bw",
1147 "serde",
1148 "serde_json",
1149 "smallvec 2.0.0-alpha.12",
1150 "zmij",
1151]
10711152
1072[[package]]1153[[package]]
1073name = "serde_core"1154name = "serde_core"
1103 "zmij",1184 "zmij",
1104]1185]
1105
1106[[package]]
1107name = "serde_yaml_with_quirks"
1108version = "0.9.34"
1109source = "registry+https://github.com/rust-lang/crates.io-index"
1110checksum = "d852180e55e824bb347a8e3cdbbca1f02513ea1fa00188f1b2a8a255ac3d6cf9"
1111dependencies = [
1112 "indexmap",
1113 "itoa",
1114 "ryu",
1115 "serde",
1116 "unsafe-libyaml",
1117]
11181186
1119[[package]]1187[[package]]
1120name = "sha1"1188name = "sha1"
1166source = "registry+https://github.com/rust-lang/crates.io-index"1234source = "registry+https://github.com/rust-lang/crates.io-index"
1167checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"1235checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
1236
1237[[package]]
1238name = "smallvec"
1239version = "2.0.0-alpha.12"
1240source = "registry+https://github.com/rust-lang/crates.io-index"
1241checksum = "ef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857"
11681242
1169[[package]]1243[[package]]
1170name = "stacker"1244name = "stacker"
1338source = "registry+https://github.com/rust-lang/crates.io-index"1412source = "registry+https://github.com/rust-lang/crates.io-index"
1339checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"1413checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
1340
1341[[package]]
1342name = "unsafe-libyaml"
1343version = "0.2.11"
1344source = "registry+https://github.com/rust-lang/crates.io-index"
1345checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
13461414
1347[[package]]1415[[package]]
1348name = "utf8parse"1416name = "utf8parse"
1365 "wit-bindgen",1433 "wit-bindgen",
1366]1434]
1435
1436[[package]]
1437name = "wasm-bindgen"
1438version = "0.2.108"
1439source = "registry+https://github.com/rust-lang/crates.io-index"
1440checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566"
1441dependencies = [
1442 "cfg-if",
1443 "once_cell",
1444 "rustversion",
1445 "wasm-bindgen-macro",
1446 "wasm-bindgen-shared",
1447]
1448
1449[[package]]
1450name = "wasm-bindgen-macro"
1451version = "0.2.108"
1452source = "registry+https://github.com/rust-lang/crates.io-index"
1453checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608"
1454dependencies = [
1455 "quote",
1456 "wasm-bindgen-macro-support",
1457]
1458
1459[[package]]
1460name = "wasm-bindgen-macro-support"
1461version = "0.2.108"
1462source = "registry+https://github.com/rust-lang/crates.io-index"
1463checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55"
1464dependencies = [
1465 "bumpalo",
1466 "proc-macro2",
1467 "quote",
1468 "syn",
1469 "wasm-bindgen-shared",
1470]
1471
1472[[package]]
1473name = "wasm-bindgen-shared"
1474version = "0.2.108"
1475source = "registry+https://github.com/rust-lang/crates.io-index"
1476checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12"
1477dependencies = [
1478 "unicode-ident",
1479]
13671480
1368[[package]]1481[[package]]
1369name = "windows-link"1482name = "windows-link"
modifiedCargo.tomldiffbeforeafterboth
35clap_complete = "4.5"35clap_complete = "4.5"
3636
37# Parsing, manifestification is implemented manually everywhere37# Parsing, manifestification is implemented manually everywhere
38# Note on serde_yaml_with_quirks: This is a fork of serde-yaml with legacy yaml 1.1 support:
39# https://github.com/dtolnay/serde-yaml/pull/225
40serde = "1.0.228"38serde = "1.0.228"
41serde_json = "1.0.149"39serde_json = "1.0.149"
42serde_yaml_with_quirks = "0.9.34"40serde-saphyr = {version = "0.0.17", default-features = false}
4341
44# Error handling42# Error handling
45anyhow = "1.0.101"43anyhow = "1.0.101"
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
41base64.workspace = true41base64.workspace = true
42# std.parseJson42# std.parseJson
43serde_json.workspace = true43serde_json.workspace = true
44# std.parseYaml, custom library fork is used for C++/golang compatibility44# std.parseYaml
45serde_yaml_with_quirks.workspace = true45serde-saphyr.workspace = true
4646
47num-bigint = { workspace = true, optional = true }47num-bigint = { workspace = true, optional = true }
4848
modifiedcrates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth
1use jrsonnet_evaluator::{function::builtin, runtime_error, IStr, Result, Val};1use jrsonnet_evaluator::{function::builtin, runtime_error, IStr, Result, Val};
2use serde::Deserialize;
32
4#[builtin]3#[builtin]
5pub fn builtin_parse_json(str: IStr) -> Result<Val> {4pub fn builtin_parse_json(str: IStr) -> Result<Val> {
109
11#[builtin]10#[builtin]
12pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {11pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {
13 use serde_yaml_with_quirks::DeserializingQuirks;
14 let value = serde_yaml_with_quirks::Deserializer::from_str_with_quirks(12 let out = serde_saphyr::from_multiple_with_options::<Val>(
15 &str,13 &str,
16 DeserializingQuirks { old_octals: true },14 serde_saphyr::Options {
17 );15 // Golang/C++ compat
18 let mut out = vec![];16 legacy_octal_numbers: true,
19 for item in value {17 // Disable budget limits - we trust the YAML input
20 let val =18 budget: None,
19 ..Default::default()
20 },
21 )
21 Val::deserialize(item).map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;22 .map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;
22 out.push(val);
23 }
24 Ok(if out.is_empty() {23 Ok(if out.is_empty() {
25 Val::Null24 Val::Null
26 } else if out.len() == 1 {25 } else if out.len() == 1 {