Crates.io | serde_dbgfmt |
lib.rs | serde_dbgfmt |
version | 0.1.0 |
source | src |
created_at | 2024-02-02 08:04:38.209334 |
updated_at | 2024-02-02 08:04:38.209334 |
description | Deserialize #[derive(Debug)] output using serde |
homepage | |
repository | https://github.com/phantomical/serde_dbgfmt |
max_upload_size | |
id | 1124128 |
size | 67,559 |
Deserialize the output of #[derive(Debug)]
using serde
.
This library allows you to deserialize the debug representation of rust types
via serde
. This includes all types which use #[derive(Debug)]
but also any
other ones that use the debug helpers in std::fmt
to output their debug
representation.
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct Test {
message: String,
}
let text = format!("{:?}", Test { message: "Hello, World!".into() });
let value: Test = serde_defmt::from_str(&text)
.expect("failed to deserialize from the debug repr");
assert_eq!(value.message, "Hello, World!");
std::fmt
.
This should cover all types with #[derive(Debug)]
and many custom impls but
since custom impls can do anything it is not guaranteed to work.#[serde(rename = "..")]
if you want to use a
different struct name in your codebase.serde_fmt
library is the inverse of this crate. It allows you to
print a debug representation for any struct which implements [Serialize
].