cargo: bump toml_edit to 0.22.22

toml_edit now has separate immutable and mutable Document types. Other than
that, the API should be compatible.
This commit is contained in:
Yuya Nishihara 2024-11-21 16:24:45 +09:00
parent e060ef20c1
commit 99c269816c
3 changed files with 66 additions and 35 deletions

23
Cargo.lock generated
View file

@ -976,7 +976,7 @@ dependencies = [
"gix-utils",
"itoa",
"thiserror",
"winnow 0.6.18",
"winnow",
]
[[package]]
@ -1058,7 +1058,7 @@ dependencies = [
"smallvec",
"thiserror",
"unicode-bom",
"winnow 0.6.18",
"winnow",
]
[[package]]
@ -1278,7 +1278,7 @@ dependencies = [
"itoa",
"smallvec",
"thiserror",
"winnow 0.6.18",
"winnow",
]
[[package]]
@ -1390,7 +1390,7 @@ dependencies = [
"gix-validate",
"memmap2",
"thiserror",
"winnow 0.6.18",
"winnow",
]
[[package]]
@ -3249,15 +3249,15 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.19.15"
version = "0.22.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.5.40",
"winnow",
]
[[package]]
@ -3757,15 +3757,6 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "winnow"
version = "0.6.18"

View file

@ -110,7 +110,7 @@ textwrap = "0.16.1"
thiserror = "1.0.69"
timeago = { version = "0.4.2", default-features = false }
tokio = { version = "1.41.1" }
toml_edit = { version = "0.19.15", features = ["serde"] }
toml_edit = { version = "0.22.22", features = ["serde"] }
tracing = "0.1.40"
tracing-chrome = "0.7.2"
tracing-subscriber = { version = "0.3.18", default-features = false, features = [

View file

@ -586,7 +586,7 @@ fn read_config_path(config_path: &Path) -> Result<config::Config, config::Config
.build()
}
fn read_config(path: &Path) -> Result<toml_edit::Document, CommandError> {
fn read_config(path: &Path) -> Result<toml_edit::ImDocument<String>, CommandError> {
let config_toml = std::fs::read_to_string(path).or_else(|err| {
match err.kind() {
// If config doesn't exist yet, read as empty and we'll write one.
@ -605,7 +605,7 @@ fn read_config(path: &Path) -> Result<toml_edit::Document, CommandError> {
})
}
fn write_config(path: &Path, doc: &toml_edit::Document) -> Result<(), CommandError> {
fn write_config(path: &Path, doc: &toml_edit::DocumentMut) -> Result<(), CommandError> {
std::fs::write(path, doc.to_string()).map_err(|err| {
user_error_with_message(
format!("Failed to write file {path}", path = path.display()),
@ -619,7 +619,7 @@ pub fn write_config_value_to_file(
value: toml_edit::Value,
path: &Path,
) -> Result<(), CommandError> {
let mut doc = read_config(path)?;
let mut doc = read_config(path)?.into_mut();
// Apply config value
let mut target_table = doc.as_table_mut();
@ -655,7 +655,7 @@ pub fn remove_config_value_from_file(
key: &ConfigNamePathBuf,
path: &Path,
) -> Result<(), CommandError> {
let mut doc = read_config(path)?;
let mut doc = read_config(path)?.into_mut();
// Find target table
let mut key_iter = key.components();
@ -975,7 +975,7 @@ mod tests {
// Note: "email" is alphabetized, before "name" from same layer.
insta::assert_debug_snapshot!(
layered_configs.resolved_config_values(&ConfigNamePathBuf::root()).unwrap(),
@r###"
@r#"
[
AnnotatedValue {
path: ConfigNamePathBuf(
@ -983,7 +983,11 @@ mod tests {
Key {
key: "user",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -991,7 +995,11 @@ mod tests {
Key {
key: "email",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1013,7 +1021,11 @@ mod tests {
Key {
key: "user",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1021,7 +1033,11 @@ mod tests {
Key {
key: "name",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1043,7 +1059,11 @@ mod tests {
Key {
key: "user",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1051,7 +1071,11 @@ mod tests {
Key {
key: "email",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1068,7 +1092,7 @@ mod tests {
is_overridden: false,
},
]
"###
"#
);
}
@ -1099,7 +1123,7 @@ mod tests {
layered_configs
.resolved_config_values(&ConfigNamePathBuf::from_iter(["test-table1"]))
.unwrap(),
@r###"
@r#"
[
AnnotatedValue {
path: ConfigNamePathBuf(
@ -1107,7 +1131,11 @@ mod tests {
Key {
key: "test-table1",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1115,7 +1143,11 @@ mod tests {
Key {
key: "foo",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1137,7 +1169,11 @@ mod tests {
Key {
key: "test-table1",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1145,7 +1181,11 @@ mod tests {
Key {
key: "bar",
repr: None,
decor: Decor {
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
@ -1162,7 +1202,7 @@ mod tests {
is_overridden: false,
},
]
"###
"#
);
}