-1

I'm working on a wrapper for a spec called Appstream which consists of an XML file that describes a package to a software center.

I have been struggling with how can I handle a case like this one, the sepc allows you to set a description tag similar to

    <description>
        <p>
      Power Statistics is a program used to view historical and current battery
      information and will show programs running on your computer using power.
        </p>
        <p>Example list:</p>
        <ul>
            <li>First item</li>
            <li>Second item</li>
        </ul>
        <p>
      You probably only need to install this application if you are having problems
      with your laptop battery, or are trying to work out what programs are using
      significant amounts of power.
        </p>
    </description>

quick-xml (a Serde based XML library) allows you to use rename="$value" to get the inner value of the tag. The issue is that I would like to somehow get the original string before Serde tries to serialize it otherwise I will just get a Seq of tags. Is such thing even possible?

1 Answers1

0

It sounds like you might want override the implementation of the serialization of that field. Serde allows this with the serialize_with attribute: docs.

The Serialize function in the Custom Date Format shows an example of how to implement custom serialization for a property. (The with attribute used in the example is shorthand for serialize_with and deserialize_with.)

Jon G Stødle
  • 3,844
  • 1
  • 16
  • 22