Support per-field config override in derived implementations
- Vorherrschende Sprache
- Rust
- Sterne
- 224
- Forks
- 46
- Ø Merge
- 7 T. 15 Std.
- Gemergte PRs (30 T.)
- 4
Beschreibung
Sometimes the serialization format requires adjusting config only for specific fields. This is easy enough when implementing schemas manually, since config can be adjusted per-call for specific field.
However when using derives it is not available.
As mentioned in https://github.com/anza-xyz/wincode/issues/270 this can be solved by using extra helper schema provider / wrapper and `#[wincode(with = "Helper")]` attribute. However this means that for every possible config adjustment per-field user need to define specialized impl that overrides the config or re-implement the required behavior for given target type.
A more general and flexible approach would be to define config override attribute per field, e.g.
```rust
struct Foo {
a: u64,
#[wincode(config = MyCustomConfig)]
b: u64,
#[wincode(config_with = cfg => cfg.with_varint_encoding())]
c: u64,
}
```
One or both of above attributes would solve the problem, naming TBD.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.