Skip to content

Commit 1c595b8

Browse files
committed
[guides] add information about prior-version-exclusive helper functions
1 parent d385b90 commit 1c595b8

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

guides/migrating-to-versions-crate.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ In API traits and their implementations, always import `latest` and `vN` modules
4343
3. Don't create new re-exports from the API crate.
4444
4. Don't put functional (non-conversion-related) code next to versioned types. Put them in an `impls` module in the versions crate.
4545
5. The `vN::` impl signatures must exactly match the trait signatures (`vN::` paths).
46-
6. For trait endpoints with `latest::`, the impl must import the floating identifier **from the types crate**.
47-
7. For other types, strongly prefer retaining existing imports. If an existing module imports `iddqd::IdOrdMap` and uses it as `IdOrdMap`, maintain the same pattern in the destination.
48-
8. Retain all existing comments. Don't add useless comments like "parameter moved from params.rs". Be extremely sparing with added prose.
49-
9. Don't make any semantic changes. Move code AS IS, as far as possible. This is purely a reorganization.
50-
10. Do NOT delete any tests. Most tests in the types crate should move into the versions crate's `impls` module. Tests specifically for conversion between versions should be moved to version modules. Tests that use unpublished types can stay in the types crate.
46+
6. If a prior-version endpoint delegates to a helper function that exclusively serves that old version, the helper's signature must also use `vN::` paths — not floating identifiers from the types crate. Floating identifiers resolve to the latest version today, but will break when the type changes in a future version.
47+
7. For trait endpoints with `latest::`, the impl must import the floating identifier **from the types crate**.
48+
8. For other types, strongly prefer retaining existing imports. If an existing module imports `iddqd::IdOrdMap` and uses it as `IdOrdMap`, maintain the same pattern in the destination.
49+
9. Retain all existing comments. Don't add useless comments like "parameter moved from params.rs". Be extremely sparing with added prose.
50+
10. Don't make any semantic changes. Move code AS IS, as far as possible. This is purely a reorganization.
51+
11. Do NOT delete any tests. Most tests in the types crate should move into the versions crate's `impls` module. Tests specifically for conversion between versions should be moved to version modules. Tests that use unpublished types can stay in the types crate.
5152

5253
**Order of operations:**
5354

@@ -405,6 +406,8 @@ impl MyApi for MyApiImpl {
405406

406407
If a prior version is turned into a provided method, **remove it from all implementations**.
407408

409+
If the implementation delegates to helper functions that exclusively serve prior-version endpoints (e.g. `bgp_admin::get_neighbors_v4`), those helpers must also use `vN::` paths for their parameter and return types — not floating identifiers imported from the types crate.
410+
408411
## Update replace statements in client crates
409412

410413
Progenitor `replace` statements in client crates should use the `latest` re-exports in the versions crate. Update Progenitor clients to:

guides/new-version.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ In API traits, always import `latest` and `vN` modules with `use foo_versions::{
5252
3. Don't add types to the API crate. All types should live in the versions crate.
5353
4. Don't put functional (non-conversion-related) code next to versioned types. Put them in the `impls` module in the versions crate.
5454
5. The `vN::` impl signatures must exactly match the trait signatures (`vN::` paths).
55-
6. For trait endpoints with `latest::`, the impl must import the floating identifier **from the types crate**, not the versions crate.
56-
7. Retain all existing comments. Don't add useless comments. Be extremely sparing with added prose.
57-
8. Don't make unrelated changes. Focus only on the new version being added.
55+
6. If a prior-version endpoint delegates to a helper function that exclusively serves that old version, the helper's signature must also use `vN::` paths — not floating identifiers from the types crate.
56+
7. For trait endpoints with `latest::`, the impl must import the floating identifier **from the types crate**, not the versions crate.
57+
8. Retain all existing comments. Don't add useless comments. Be extremely sparing with added prose.
58+
9. Don't make unrelated changes. Focus only on the new version being added.
5859

5960
**Order of operations:**
6061

@@ -432,6 +433,10 @@ If the prior version is a provided method (the common case), no other changes ar
432433

433434
The method name has changed, so perform the corresponding updates in the implementation. Remember also to update `latest::` paths to versioned identifiers, mirroring the pattern used in the API trait.
434435

436+
#### Helper functions for prior-version endpoints
437+
438+
If prior-version endpoint implementations delegate to helper functions that exclusively serve old versions, update those helpers to use `vN::` paths as well — not floating identifiers from the types crate.
439+
435440
### Move non-conversion-related methods to newer types
436441

437442
Prior versions of types may have non-conversion-related methods or trait implementations defined for them. These methods typically need to be moved over to be implemented on the newer versions.

0 commit comments

Comments
 (0)