Merged
Conversation
sosthene-nitrokey
approved these changes
Jun 5, 2025
src/lib.rs
Outdated
Comment on lines
19
to
21
| ### Attributes | ||
|
|
||
| #### Struct attributes | ||
|
|
||
| - `auto_index`: Automatically assign indices to the fields based on the order in the source code. It is recommended to instead use the `index` attribute for all fields to explicitly assign indices. | ||
| - `offset = ?`: If `auto_index` is set, use the given index for the first field instead of starting with zero. | ||
|
|
||
| ### Field attributes | ||
|
|
||
| - `index = ?`: Set the index for this field to the given field. This attribute is required unless `auto_index` is set. It cannot be used together with `auto_index`. | ||
| - `skip`: Never serialize or deserialize this field. This field still increases the assigned index if `auto_index` is used. | ||
| - `skip(no_increment)`: Never serialize or deserialize this field and don’t increment the assigned index for this field if used together with the `auto_index` attribute. | ||
|
|
||
| `serde-indexed` also supports these `serde` attributes: | ||
| - [`deserialize_with`][deserialize-with] | ||
| - [`serialize_with`][serialize-with] | ||
| - [`skip_serializing_if`][skip-serializing-if] | ||
| - [`with`][with] | ||
|
|
Contributor
There was a problem hiding this comment.
It would be nice to have a couple of examples.
Maybe just copy the structures used in the tests here.
4f46b7a to
21b1be6
Compare
sosthene-nitrokey
approved these changes
Jun 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds documentation for the new attributes and releases v0.2.0.