问题描述
我正在为一个名为Appstream的规范进行包装,该规范由一个XML文件组成,该XML文件描述了到软件中心的软件包。
我一直在努力处理这种情况,sepc允许您设置类似于以下内容的描述标签
<description>
<p>
Power Statistics is a program used to view historical and current battery
@R_837_4045@ion 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(基于Serde的XML库)允许您使用rename="$value"
来获取标记的内部值。问题是我想以某种方式在Serde尝试序列化之前获取原始字符串,否则我将只获得Seq标签。这样的事情有可能吗?
解决方法
听起来您可能想覆盖该字段的序列化实现。 Serde允许使用max-attempts: 6
属性:docs。
Custom Date Format中的serialize_with
函数显示了如何为属性实现自定义序列化的示例。 (示例中使用的with
属性是Serialize
和serialize_with
的简写。)