๐ ๏ธ lenient_derive
This crate provides the #[derive(LenientDeserialize)] procedural macro to enable fault-tolerant Serde deserialization for struct fields in Rust.
It is designed to work in conjunction with the lenient crate, which defines wrappers for lenient field handling using serde.
โจ Features
#[derive(LenientDeserialize)]for struct-level deserialization- Field-level
#[lenient]to fallback to default on deserialization failure - Field-level
#[optional]to fallback toNoneon failure - Designed for use with
Lenient<T>andOptional<T>wrappers - Automatically implements
Deserializefor the annotated struct
๐ฆ Example Usage
In your Cargo.toml:
[]
= "0.1"
In your Rust code:
use LenientDeserialize;
use Deserialize;
;
;
๐งช How It Works
The macro generates an internal deserialization wrapper struct like:
Then it provides a Deserialize implementation for the outer struct using the inner one.
๐ License
MIT