xso-proc: Add support for the codec field on attribute meta
This allows a custom TextCodec to be used for encoding and decoding the attribute’s value, instead of FromXmlText and AsOptionalXmlText.
This commit is contained in:
parent
763a603e49
commit
01a0c51a2f
6 changed files with 114 additions and 5 deletions
|
|
@ -29,6 +29,8 @@ Version NEXT:
|
|||
translated into a boolean (`#[xml(flag)]`).
|
||||
- Generic TextCodec implementation for all base64 engines provided by
|
||||
the base64 crate (if the `base64` feature is enabled).
|
||||
- New `codec` field on `attribute` meta, to support decoding and
|
||||
encoding using any `TextCodec`.
|
||||
|
||||
Version 0.1.2:
|
||||
2024-07-26 Jonas Schäfer <jonas@zombofant.net>
|
||||
|
|
|
|||
|
|
@ -263,6 +263,7 @@ The following keys can be used inside the `#[xml(attribute(..))]` meta:
|
|||
| `name` | optional *string literal* or *path* | The name of the XML attribute to match. If it is a *path*, it must point at a `&'static NcNameStr`. |
|
||||
| `default` | *flag* | If present, an absent attribute will substitute the default value instead of raising an error. |
|
||||
| `type_` | *type* | Optional explicit type specification. Only allowed within `#[xml(extract(fields(..)))]`. |
|
||||
| `codec` | optional *expression* | [`TextCodec`] implementation which is used to encode or decode the field. |
|
||||
|
||||
If the `name` key contains a namespace prefix, it must be one of the prefixes
|
||||
defined as built-in in the XML specifications. That prefix will then be
|
||||
|
|
@ -284,6 +285,9 @@ If `type_` is specified and the `text` meta is used within an
|
|||
`#[xml(extract(fields(..)))]` meta, the specified type is used instead of the
|
||||
field type on which the `extract` is declared.
|
||||
|
||||
If `codec` is given, the given `codec` value must implement
|
||||
[`TextCodec<T>`][`TextCodec`] where `T` is the type of the field.
|
||||
|
||||
#### Example
|
||||
|
||||
```rust
|
||||
|
|
|
|||
Loading…
Reference in a new issue