Skip to main content

FHIRSerdeSerialize

Derive Macro FHIRSerdeSerialize 

Source
#[derive(FHIRSerdeSerialize)]
{
    // Attributes available to this derive:
    #[fhir_serialize_type]
    #[rename_field]
    #[type_choice_field_name]
    #[type_choice_variants]
    #[primitive]
    #[code]
    #[cardinality]
    #[reference]
    #[fhir_resource_type]
}
Expand description

Derives Serde-based FHIR JSON serialization implementations.

The macro behavior is selected using the fhir_serialize_type attribute.

Supported serialization types:

  • primitive
  • valueset
  • typechoice
  • complex
  • resource
  • enum-variant

§Panics

Panics if:

  • The fhir_serialize_type attribute is missing.
  • The fhir_serialize_type attribute contains an unsupported value.

§Attributes

This macro supports the following attributes:

  • fhir_serialize_type - Selects the serialization implementation.
  • rename_field - Renames a serialized field.
  • type_choice_field_name - Defines the field name used for type choice serialization.
  • type_choice_variants - Defines variants for type choice fields.
  • primitive - Marks primitive FHIR fields.
  • code - Marks code fields.
  • cardinality - Defines validation cardinality constraints.
  • reference - Marks reference fields.
  • fhir_resource_type - Overrides the FHIR resource type name.