Crates.io | figa-proc |
lib.rs | figa-proc |
version | 0.1.0 |
source | src |
created_at | 2023-09-26 17:50:59.005234 |
updated_at | 2023-09-26 17:50:59.005234 |
description | Proc-macro for 'figa' crate |
homepage | |
repository | https://gihub.com/zakarumych/figa |
max_upload_size | |
id | 983929 |
size | 15,514 |
Augments serde
deserialization with customizeable updating mechanism.
This crate provides Figa
trait to update values using serde
deserialization.
The trait uses single method update
.
The magic happens in derive macro. Enable "derive"
feature to make it re-exported from figa
crate, or use figa-proc
crate directly.
Derive macro currently supports only structs without generics.
User may customize update behavior for struct fields using #[figa(*)]
attribute:
#[figa(replace)]
tells the codegen that field's value must be replaced with the new one.#[figa(append)]
works for collections and tells the codegen that this field is a collection and new elements must be added.
In case of maps, if value with the same key was present it will be replaced with new one.
For Vec
and String
appended values are added to the end as expected.#[figa(update)]
tells the codegen that field must be updated.
This means that Figa::update
will be called on for it recursively.
For collections this means that values with same keys or indices are updated using Figa
trait
and new values are appended.load
featureprovides opinionated way to load configuration from .toml
files in predefined set of locations.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.