pub trait TextCodec<T> {
    // Required methods
    fn decode(&self, s: String) -> Result<T, Error>;
    fn encode<'x>(&self, value: &'x T) -> Result<Option<Cow<'x, str>>, Error>;
    // Provided method
    fn filtered<F: TextFilter>(self, filter: F) -> Filtered<F, Self, T>
       where Self: Sized { ... }
}Expand description
Represent a way to encode/decode text data into a Rust type.
This trait can be used in scenarios where implementing FromXmlText
and/or AsXmlText on a type is not feasible or sensible, such as the
following:
- 
The type originates in a foreign crate, preventing the implementation of foreign traits.
 - 
There is more than one way to convert a value to/from XML.
 
The codec to use for a text can be specified in the attributes understood
by FromXml and AsXml derive macros. See the documentation of the
FromXml derive macro for details.
Required Methods§
Provided Methods§
Sourcefn filtered<F: TextFilter>(self, filter: F) -> Filtered<F, Self, T>where
    Self: Sized,
 
fn filtered<F: TextFilter>(self, filter: F) -> Filtered<F, Self, T>where
    Self: Sized,
Apply a filter to this codec.
Filters preprocess strings before they are handed to the codec for parsing, allowing to, for example, make the codec ignore irrelevant content by stripping it.
Implementors§
impl TextCodec<String> for EmptyAsError
impl TextCodec<String> for Plain
impl TextCodec<Vec<u8>> for Base64
Available on crate feature 
base64 only.impl TextCodec<Vec<u8>> for ColonSeparatedHex
impl<'x> TextCodec<Cow<'x, [u8]>> for Base64
Available on crate feature 
base64 only.impl<T> TextCodec<Option<T>> for Base64
Available on crate feature 
base64 only.impl<T> TextCodec<Option<T>> for EmptyAsNonewhere
    T: FromXmlText + AsXmlText,
impl<T, F: TextFilter, C: TextCodec<T>> TextCodec<T> for Filtered<F, C, T>
impl<T, U> TextCodec<Option<U>> for T
Available on crate feature 
base64 only.impl<T, const N: usize> TextCodec<Option<T>> for FixedHex<N>
impl<T: Engine> TextCodec<Vec<u8>> for T
Available on crate feature 
base64 only.