fig-macros 3.0.2

Derive macros (ToValue/FromValue) for the `fig` crate.
Documentation

Derive macros for the fig crate's ToValue/FromValue traits.

These generate straight-line conversions to and from fig::Value — no format-generic visitor machinery, so the emitted code stays small. The macros are re-exported from fig behind its derive feature; depend on fig, not on this crate directly.

Structs

Named-field, newtype (one field), and unit structs. Field attributes: #[fig(rename = "..")], #[fig(skip)], #[fig(flatten)], #[fig(default)] or #[fig(default = "path")] (call path() for a missing key), #[fig(skip_serializing_if = "path")] (omit from ToValue output when the predicate fn(&Field) -> bool is true), and #[fig(deserialize_with = "path")] (parse a present value with path(&fig::Value) -> Result<Field, fig::Error>). Option<_> fields are optional (absent key → None). The container attribute #[fig(rename_all = "..")] applies a case rule (camelCase, snake_case, PascalCase, kebab-case, and their SCREAMING variants, plus lowercase/UPPERCASE) to every field name not carrying an explicit rename.

Enums

All four serde-style taggings, chosen by container attribute:

  • external (default) — "Variant" / { "Variant": <content> }
  • internal — #[fig(tag = "type")]{ "type": "Variant", ..fields }
  • adjacent — #[fig(tag = "type", content = "data")]
  • untagged — #[fig(untagged)] (first matching variant wins, in order)

Variant shapes: unit, newtype, tuple, struct. Variant #[fig(rename = "..")] is honored, and the container #[fig(rename_all = "..")] applies to variant names (matching serde — it does not rename a struct-variant's inner fields). Restrictions (matching/extending serde): tuple variants are not allowed with internal tagging, and #[fig(flatten)] is not yet supported inside enum variants.