Attribute Macro obake::versioned

source ·
#[versioned]
Expand description

The core macro of the library. Used to declare versioned data-structures.

Supported attributes:

  • #[obake(version("x.y.z"))] - Declares a possible version of the data-structure.
  • #[obake(cfg(...))] - Specifies a semantic version constraints for a particular field or variant.
    • cfg can contain any number of comma-separated semantic version constraints (e.g., #[obake(cfg(">=0.3, <=0.1"))]).
    • A field or variant marked with a cfg attribute will only appear in a particular version of the data-structure type all of the attributes constraints are satisfied by that version.
    • In the presence of multiple cfg attributes, any matching cfg will result in a match (i.e., while comman-seperated constraints are treated as a conjunctively, multiple cfg attributes are treated as a disjunctively).
  • #[obake(derive(...))] - Apply a derive to the version-tagged enum generated for the data-structre.
  • #[obake(serde(...))] - Apply a serde attribute to the version-tagged enum generated for the data-structre.
    • Note: requires the feature serde.
  • #[obake(inherit)] - Marks a field as having an inherited version (i.e., given a field of type Bar, when marked with inherit, this field will be expanded to a field of type Bar![{version}] in every version).