From 8dc4465c58d1f7cbe33c5d5fac564169f1e375d2 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 29 Jun 2024 21:11:05 +0300 Subject: [PATCH] Fix toml value ser after update of toml dependency Update in v0.8.5 required changes to serialization code; toml::to_string() now serializes TOML documents, not values. This commit replaces all occurances with toml::Value serializations. Fixes: 8fff7401 ("Update yanked zerocopy dependency") Closes: #429 Signed-off-by: Manos Pitsidianakis --- meli/src/conf.rs | 36 +++++++++++++++++++++++++--------- meli/src/conf/listing.rs | 4 +++- meli/src/conf/notifications.rs | 4 +++- meli/src/conf/pager.rs | 4 +++- meli/src/conf/shortcuts.rs | 6 ++++-- meli/src/conf/tags.rs | 4 +++- meli/src/conf/terminal.rs | 4 +++- meli/src/conf/themes.rs | 15 ++++++++------ 8 files changed, 55 insertions(+), 22 deletions(-) diff --git a/meli/src/conf.rs b/meli/src/conf.rs index 96cda8f9..fccadb92 100644 --- a/meli/src/conf.rs +++ b/meli/src/conf.rs @@ -1061,7 +1061,9 @@ mod dotaddressable { std::any::type_name::() ))) } else { - Ok(toml::to_string(self).map_err(|err| err.to_string())?) + Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()) } } } @@ -1112,7 +1114,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1140,7 +1144,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1161,7 +1167,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1196,7 +1204,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1215,7 +1225,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1245,7 +1257,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1272,7 +1286,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -1295,7 +1311,9 @@ mod dotaddressable { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/listing.rs b/meli/src/conf/listing.rs index d0da035b..f8d567a3 100644 --- a/meli/src/conf/listing.rs +++ b/meli/src/conf/listing.rs @@ -252,7 +252,9 @@ impl DotAddressable for ListingSettings { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/notifications.rs b/meli/src/conf/notifications.rs index 2d5100c6..3017ef6c 100644 --- a/meli/src/conf/notifications.rs +++ b/meli/src/conf/notifications.rs @@ -88,7 +88,9 @@ impl DotAddressable for NotificationsSettings { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/pager.rs b/meli/src/conf/pager.rs index cadbba05..591e1509 100644 --- a/meli/src/conf/pager.rs +++ b/meli/src/conf/pager.rs @@ -176,7 +176,9 @@ impl DotAddressable for PagerSettings { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/shortcuts.rs b/meli/src/conf/shortcuts.rs index bf0905f8..2a42182a 100644 --- a/meli/src/conf/shortcuts.rs +++ b/meli/src/conf/shortcuts.rs @@ -83,7 +83,9 @@ impl DotAddressable for Shortcuts { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } @@ -148,7 +150,7 @@ macro_rules! shortcut_key_values { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self).map_err(|err| err.to_string())?.to_string()), } } } diff --git a/meli/src/conf/tags.rs b/meli/src/conf/tags.rs index 3f627620..49b9df00 100644 --- a/meli/src/conf/tags.rs +++ b/meli/src/conf/tags.rs @@ -93,7 +93,9 @@ impl DotAddressable for TagsSettings { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/terminal.rs b/meli/src/conf/terminal.rs index c12c6a89..1b242696 100644 --- a/meli/src/conf/terminal.rs +++ b/meli/src/conf/terminal.rs @@ -113,7 +113,9 @@ impl DotAddressable for TerminalSettings { ))), } } - None => Ok(toml::to_string(self).map_err(|err| err.to_string())?), + None => Ok(toml::Value::try_from(self) + .map_err(|err| err.to_string())? + .to_string()), } } } diff --git a/meli/src/conf/themes.rs b/meli/src/conf/themes.rs index 5abbee6a..8d981604 100644 --- a/meli/src/conf/themes.rs +++ b/meli/src/conf/themes.rs @@ -1250,9 +1250,12 @@ impl Themes { ret, "\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}", k, - toml::to_string(&unlink_fg(theme, &ColorField::Fg, k)).unwrap(), - toml::to_string(&unlink_bg(theme, &ColorField::Bg, k)).unwrap(), - toml::to_string(&unlink_attrs(theme, k)).unwrap(), + toml::Value::try_from(unlink_fg(theme, &ColorField::Fg, k)) + .expect("Could not serialize Color"), + toml::Value::try_from(unlink_bg(theme, &ColorField::Bg, k)) + .expect("Could not serialize Color"), + toml::Value::try_from(unlink_attrs(theme, k)) + .expect("Could not serialize Attribute"), ); } } else { @@ -1261,9 +1264,9 @@ impl Themes { ret, "\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}", k, - toml::to_string(&theme[k].fg).unwrap(), - toml::to_string(&theme[k].bg).unwrap(), - toml::to_string(&theme[k].attrs).unwrap(), + toml::Value::try_from(&theme[k].fg).expect("Could not serialize Color"), + toml::Value::try_from(&theme[k].bg).expect("Could not serialize Color"), + toml::Value::try_from(&theme[k].attrs).expect("Could not serialize Attribute") ); } }