Skip to content

Conversation

robin-nitrokey
Copy link
Member

This PR adds documentation for the new attributes and releases v0.2.0.

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]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a couple of examples.

Maybe just copy the structures used in the tests here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@robin-nitrokey robin-nitrokey merged commit 21b1be6 into main Jun 6, 2025
8 checks passed
@robin-nitrokey robin-nitrokey deleted the release-v0.2.0 branch June 6, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants