Skip to main content

struct_name

Function struct_name 

Source
pub fn struct_name(
    sd: &StructureDefinition,
    element: &ElementDefinition,
) -> String
Expand description

Returns the generated Rust struct name for a FHIR element.

For the root element, the struct name is derived from the structure definition’s id. Primitive FHIR types are prefixed with "FHIR" to distinguish them from Rust primitive types (e.g. stringFHIRString).

For nested elements, the struct name is constructed by:

  • Splitting the element id on '.'.
  • Capitalizing each path segment.
  • Concatenating the segments.
  • Removing the FHIR choice-type marker ([x]), if present.

§Panics

This function will panic if:

  • The root [StructureDefinition] does not have an id.
  • A non-root [ElementDefinition] does not have an id.

§Arguments

  • sd - The [StructureDefinition] containing the element.
  • element - The [ElementDefinition] for which to generate a struct name.

§Returns

A String containing the generated Rust struct name.