pub struct InvariantGenerator;Expand description
Generator for invariant constants
Implementations§
Source§impl InvariantGenerator
impl InvariantGenerator
Sourcepub fn generate_invariants_constant(
structure_def: &StructureDefinition,
) -> String
pub fn generate_invariants_constant( structure_def: &StructureDefinition, ) -> String
Generate a INVARIANTS constant for a StructureDefinition
Returns Rust code as a string containing the lazy static declaration, or an empty string if there are no invariants.
Uses once_cell::sync::Lazy for runtime initialization since Invariant::new()
is not a const fn (it uses .into() for String conversions).
Example output:
ⓘ
pub static INVARIANTS: once_cell::sync::Lazy<Vec<rh_foundation::Invariant>> =
once_cell::sync::Lazy::new(|| vec![
rh_foundation::Invariant::new(
"pat-1",
rh_foundation::Severity::Error,
"SHALL at least contain a contact's details or a reference to an organization",
"name.exists() or telecom.exists() or address.exists() or organization.exists()"
).with_xpath(""),
]);Sourcepub fn generate_invariants_tokens(
structure_def: &StructureDefinition,
) -> TokenStream
pub fn generate_invariants_tokens( structure_def: &StructureDefinition, ) -> TokenStream
Generate invariants constant using quote! macro (alternative implementation)
This generates the same output but uses proc_macro2::TokenStream, which can be useful for integration with other token-based code generation.
Auto Trait Implementations§
impl Freeze for InvariantGenerator
impl RefUnwindSafe for InvariantGenerator
impl Send for InvariantGenerator
impl Sync for InvariantGenerator
impl Unpin for InvariantGenerator
impl UnsafeUnpin for InvariantGenerator
impl UnwindSafe for InvariantGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more