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:
Jonas Schäfer 2024-08-03 10:51:23 +02:00
commit 271c31c9d4
10 changed files with 150 additions and 101 deletions

View file

@ -408,7 +408,7 @@ pub(crate) enum XmlFieldMeta {
/// `#[xml(text)]`
Text {
/// The path to the optional codec type.
codec: Option<Type>,
codec: Option<Expr>,
},
/// `#[xml(child)`
@ -497,7 +497,7 @@ impl XmlFieldMeta {
/// Parse a `#[xml(text)]` meta.
fn text_from_meta(meta: ParseNestedMeta<'_>) -> Result<Self> {
let mut codec: Option<Type> = None;
let mut codec: Option<Expr> = None;
if meta.input.peek(Token![=]) {
Ok(Self::Text {
codec: Some(meta.value()?.parse()?),