difftreelog
refactor replace serde-yaml with serde-saphyr for yaml parsing
in: master
4 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,6 +3,19 @@
version = 4
[[package]]
+name = "ahash"
+version = "0.8.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
+dependencies = [
+ "cfg-if",
+ "getrandom",
+ "once_cell",
+ "version_check",
+ "zerocopy",
+]
+
+[[package]]
name = "aho-corasick"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -110,6 +123,12 @@
]
[[package]]
+name = "arraydeque"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
+
+[[package]]
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -303,6 +322,24 @@
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
+name = "encoding_rs"
+version = "0.8.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "encoding_rs_io"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83"
+dependencies = [
+ "encoding_rs",
+]
+
+[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -376,9 +413,11 @@
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
+ "js-sys",
"libc",
"r-efi",
"wasip2",
+ "wasm-bindgen",
]
[[package]]
@@ -434,7 +473,7 @@
"rand",
"random_color",
"range-map",
- "smallvec",
+ "smallvec 1.15.1",
"tree-sitter-highlight",
"unicode-box-drawing",
]
@@ -641,8 +680,8 @@
"regex",
"rustc-hash 2.1.1",
"serde",
+ "serde-saphyr",
"serde_json",
- "serde_yaml_with_quirks",
"sha1",
"sha2",
"sha3",
@@ -657,6 +696,16 @@
]
[[package]]
+name = "js-sys"
+version = "0.3.85"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3"
+dependencies = [
+ "once_cell",
+ "wasm-bindgen",
+]
+
+[[package]]
name = "json-structural-diff"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -772,6 +821,12 @@
]
[[package]]
+name = "nohash-hasher"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
+
+[[package]]
name = "num-bigint"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1054,10 +1109,15 @@
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
-name = "ryu"
-version = "1.0.22"
+name = "saphyr-parser-bw"
+version = "0.0.607"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984"
+checksum = "2f9bae8d059bf1ca32753cf3cdafbf5d391502de2fc2ca54510811fe9c100d90"
+dependencies = [
+ "arraydeque",
+ "smallvec 2.0.0-alpha.12",
+ "thiserror",
+]
[[package]]
name = "serde"
@@ -1070,6 +1130,27 @@
]
[[package]]
+name = "serde-saphyr"
+version = "0.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc14a55107113a16346915d7e3d78acc539a923458385db89670e22cac106d7a"
+dependencies = [
+ "ahash",
+ "annotate-snippets",
+ "base64",
+ "encoding_rs_io",
+ "getrandom",
+ "nohash-hasher",
+ "num-traits",
+ "regex",
+ "saphyr-parser-bw",
+ "serde",
+ "serde_json",
+ "smallvec 2.0.0-alpha.12",
+ "zmij",
+]
+
+[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1101,19 +1182,6 @@
"serde",
"serde_core",
"zmij",
-]
-
-[[package]]
-name = "serde_yaml_with_quirks"
-version = "0.9.34"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d852180e55e824bb347a8e3cdbbca1f02513ea1fa00188f1b2a8a255ac3d6cf9"
-dependencies = [
- "indexmap",
- "itoa",
- "ryu",
- "serde",
- "unsafe-libyaml",
]
[[package]]
@@ -1167,6 +1235,12 @@
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
+name = "smallvec"
+version = "2.0.0-alpha.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857"
+
+[[package]]
name = "stacker"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1337,12 +1411,6 @@
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
-
-[[package]]
-name = "unsafe-libyaml"
-version = "0.2.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "utf8parse"
@@ -1366,6 +1434,51 @@
]
[[package]]
+name = "wasm-bindgen"
+version = "0.2.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,11 +35,9 @@
clap_complete = "4.5"
# Parsing, manifestification is implemented manually everywhere
-# Note on serde_yaml_with_quirks: This is a fork of serde-yaml with legacy yaml 1.1 support:
-# https://github.com/dtolnay/serde-yaml/pull/225
serde = "1.0.228"
serde_json = "1.0.149"
-serde_yaml_with_quirks = "0.9.34"
+serde-saphyr = {version = "0.0.17", default-features = false}
# Error handling
anyhow = "1.0.101"
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -41,8 +41,8 @@
base64.workspace = true
# std.parseJson
serde_json.workspace = true
-# std.parseYaml, custom library fork is used for C++/golang compatibility
-serde_yaml_with_quirks.workspace = true
+# std.parseYaml
+serde-saphyr.workspace = true
num-bigint = { workspace = true, optional = true }
crates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth1use jrsonnet_evaluator::{function::builtin, runtime_error, IStr, Result, Val};1use jrsonnet_evaluator::{function::builtin, runtime_error, IStr, Result, Val};2use serde::Deserialize;324#[builtin]3#[builtin]5pub fn builtin_parse_json(str: IStr) -> Result<Val> {4pub fn builtin_parse_json(str: IStr) -> Result<Val> {10911#[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++ compat18 let mut out = vec![];16 legacy_octal_numbers: true,19 for item in value {17 // Disable budget limits - we trust the YAML input20 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::Null26 } else if out.len() == 1 {25 } else if out.len() == 1 {