use ron::ser::PrettyConfig;
use serde::de::DeserializeOwned;
use serde::Serialize;
pub use ron::error::SpannedError as RonDeserialisationError;
pub use ron::Error as RonSerialisationError;
pub fn serialize<T>(data: &T) -> Result<String, RonSerialisationError>
where
T: Serialize,
{
let config = PrettyConfig::new()
.struct_names(true)
.number_suffixes(true);
ron::ser::to_string_pretty(
data, config,
)
}
pub fn deserialize<T, S>(text: S) -> Result<T, RonDeserialisationError>
where
S: AsRef<str>,
T: DeserializeOwned,
{
let inner = |text: &str| ron::from_str::<T>(text);
inner(text.as_ref())
}