xso: use values instead of types for text codecs
This allows stateful or configurable codecs without having to express all configuration in the type name itself. For example, we could have a Base64 type with configurable Base64 engines without having to duplicate the Base64 type itself. (Note that the different engines in the Base64 crate are values, not types.)
This commit is contained in:
parent
b9fc15977b
commit
271c31c9d4
10 changed files with 150 additions and 101 deletions
|
|
@ -35,6 +35,7 @@ such:
|
|||
is also a path.
|
||||
- *string literal*: A string literal, like `"hello world!"`.
|
||||
- *type*: A Rust type.
|
||||
- *expression*: A Rust expression.
|
||||
- *ident*: A Rust identifier.
|
||||
- flag: Has no value. The key's mere presence has relevance and it must not be
|
||||
followed by a `=` sign.
|
||||
|
|
@ -258,9 +259,9 @@ element.
|
|||
|
||||
| Key | Value type | Description |
|
||||
| --- | --- | --- |
|
||||
| `codec` | *type* | Optional [`TextCodec`] implementation which is used to encode or decode the field. |
|
||||
| `codec` | *expression* | Optional [`TextCodec`] implementation which is used to encode or decode the field. |
|
||||
|
||||
If `codec` is given, the given `codec` must implement
|
||||
If `codec` is given, the given `codec` value must implement
|
||||
[`TextCodec<T>`][`TextCodec`] where `T` is the type of the field.
|
||||
|
||||
If `codec` is *not* given, the field's type must implement [`FromXmlText`] for
|
||||
|
|
|
|||
Loading…
Reference in a new issue