Skip to main content

VersionBoundary

Derive Macro VersionBoundary 

Source
#[derive(VersionBoundary)]
{
    // Attributes available to this derive:
    #[thisversion]
}
Expand description

Connects a family’s latest schema version to its application model.

Apply this derive to the final variant’s payload in a VersionFamily. The family determines version order; this derive generates the model conversions and does not check family membership or position.

Requires #[thisversion(model = Model)] and matching field names. With no error option, generates IntoModel, its TryIntoModel<Error = Infallible> adapter, and the model’s IntoSchema<S>. With #[thisversion(model = Model, error = E)], generates fallible TryIntoModel and IntoSchema<S>.

Model -> schema conversion constructs this schema’s value, then converts it into the requested S through From.

Mark a field with #[thisversion(nested)] to recursively convert a family wrapper in both directions. A bare schema value can name its family with #[thisversion(nested = Family)]; loading wraps it in that family and migrates it forward. Saving back to the pinned schema is available only when the child model implements IntoSchema<S>.