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
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
use xso::{
|
||||
error::Error,
|
||||
text::{Base64, StripWhitespace},
|
||||
text::{Base64, StripWhitespace, TextCodec},
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ pub struct Type {
|
|||
#[xml(namespace = ns::VCARD, name = "BINVAL")]
|
||||
pub struct Binval {
|
||||
/// The actual data.
|
||||
#[xml(text(codec = Base64<StripWhitespace>))]
|
||||
#[xml(text(codec = Base64.filtered(StripWhitespace)))]
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue