1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::debug::Path;
use std::{borrow::Cow, io::Write};
use xml::{writer::Error as XmlError, EventWriter};
#[derive(Debug, thiserror::Error)]
pub enum SerializeError {
#[error("XmlWrite failed - {0}")]
XmlWriteError(#[from] XmlError),
#[error("Invalid data found at {path}. {detail}")]
Invalid {
path: String,
detail: String,
},
}
pub type SerializeResult<R> = std::result::Result<R, SerializeError>;
pub trait SerializableElement {
fn serialize<W: Write>(
&self,
writer: &mut EventWriter<W>,
path: Path<'_>,
) -> SerializeResult<()>;
}
pub trait SerializableValue {
fn serialize(&self) -> Cow<'_, str>;
}