Struct Patch
A lib help you patch Rust instance, and easy to partial update configures.
Introduction
A derive macro struct_patch::Patch
helps you generate patch structure with all fields in optional,
and implement struct_patch::traits::Patch
,
such that we can partial update with apply
method.
Quick Example
use Patch;
use ;
Attributes
Following are attributes you can easy to use patch a struct as you want
patch_derive
: passing the derives to patch structpatch_name
: specify the patch struct name, default name is {struct name}Patch
Methods for original structure
The struct_patch::traits::Patch
will implement, you can check the docs for details.
apply
: apply the patch, only update the existing fieldsinto_patch_by_diff
: diff on a previous state and get the patch instancedefault_patch
: get an empty patch instance
Methods for patch structure
With status
feature, the patch struct will implement PatchStatus
trait and providing following methods:
is_empty
: check there is anything in the patch