Skip to content

Commit 9eded3a

Browse files
committed
deps: switch to serde_yaml_bw
serde_yml (which we used before) and serde_yaml are both unmaintained now, and serde_yml was using a yaml parser that's itself unsupported and unmaintained. Thankfully, looks like serde_yaml_bw is a drop-in replacement.
1 parent 74fc92a commit 9eded3a

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

Cargo.lock

Lines changed: 12 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ toml-serde = ["toml", "serde"]
1515
json-serde = ["serde_json", "serde"]
1616
# Enable SourceFile support for deserializing using the "toml_edit" crate
1717
toml-edit = ["toml_edit"]
18-
# Enable SourceFile support for deserializing using the "serde_yml" crate
19-
yaml-serde = ["serde_yml", "serde"]
18+
# Enable SourceFile support for deserializing using the "serde_yaml_bw" crate
19+
yaml-serde = ["serde_yaml_bw", "serde"]
2020
# Enable reqwest-based http file fetching
2121
remote = ["reqwest", "image"]
2222
# On the off-chance native tls roots cause a problem, they can be opted out of
@@ -39,7 +39,7 @@ miette = "7.0.0"
3939
camino = "1.1.9"
4040
toml = { version = "0.9.0", optional = true }
4141
serde_json = { version = "1.0.132", optional = true }
42-
serde_yml = { version = "0.0.11", optional = true }
42+
serde_yaml_bw = { version = "2.2.0", optional = true }
4343
serde = { version = "1.0.214", optional = true, features = ["derive"] }
4444
tar = { version = "0.4.42", optional = true }
4545
zip = { version = "4.5.0", optional = true, default-features = false, features = ["aes-crypto", "bzip2", "deflate", "time", "zstd"] }

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,6 @@ pub enum AxoassetError {
345345
span: Option<miette::SourceSpan>,
346346
/// Details of the error
347347
#[source]
348-
details: serde_yml::Error,
348+
details: serde_yaml_bw::Error,
349349
},
350350
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use reqwest;
3030
#[cfg(feature = "json-serde")]
3131
pub use serde_json;
3232
#[cfg(feature = "yaml-serde")]
33-
pub use serde_yml;
33+
pub use serde_yaml_bw;
3434
pub use source::SourceFile;
3535
pub use spanned::Spanned;
3636
#[cfg(feature = "toml-serde")]

src/source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::toml_edit::DocumentMut;
1515
use crate::serde_json;
1616

1717
#[cfg(feature = "yaml-serde")]
18-
use crate::serde_yml;
18+
use crate::serde_yaml_bw;
1919

2020
/// The inner contents of a [`SourceFile`][].
2121
#[derive(Eq, PartialEq)]
@@ -134,7 +134,7 @@ impl SourceFile {
134134
/// Try to deserialize the contents of the SourceFile as yaml
135135
#[cfg(feature = "yaml-serde")]
136136
pub fn deserialize_yaml<'a, T: for<'de> serde::Deserialize<'de>>(&self) -> Result<T> {
137-
let yaml = serde_yml::from_str(self.contents()).map_err(|details| {
137+
let yaml = serde_yaml_bw::from_str(self.contents()).map_err(|details| {
138138
let span = details
139139
.location()
140140
.and_then(|location| self.span_for_line_col(location.line(), location.column()));

tests/source.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ goodbye: true
225225
#[test]
226226
#[cfg(feature = "yaml-serde")]
227227
fn yaml_invalid() {
228-
use axoasset::AxoassetError;
229-
230228
#[derive(serde::Deserialize, PartialEq, Eq, Debug)]
231229
struct MyType {
232230
hello: String,
@@ -243,8 +241,9 @@ goodbye: "this shouldn't be a string"
243241
let source = axoasset::SourceFile::new("file.yml", contents);
244242

245243
let res = source.deserialize_yaml::<MyType>();
244+
// In a previous version, we had an assertion that the span
245+
// was filled out here. Unfortunately, the span isn't always
246+
// available in the yaml library we had to switch to;
247+
// investigate other options in the future.
246248
assert!(res.is_err());
247-
let Err(AxoassetError::Yaml { span: Some(_), .. }) = res else {
248-
panic!("span was invalid");
249-
};
250249
}

0 commit comments

Comments
 (0)