Skip to content

Attributes

The attributes allow to further apply configuration to elements, while not affecting the schema itself. These rather provide either extra information or customize how language specific code is generated.

For example, they allow to mark elements as deprecated or define how a certain value is represented in code, off the default variant.

Attributes can come in 3 forms.

  • Unit, just having the name of the attribute itself.
  • Singe-value, with a literal assignment (can be optional).
  • Multi-value, as an object that can have multiple sub-attributes.
#[deprecated]
struct Sample {}
#[deprecated = "Don't use anymore"]
struct Sample {}
struct Sample {
#[validate(min = 1, max = 100)]
age: u8 @1,
}