mysqldump_quick_xml/
lib.rs

1/*!
2Crate `mysqldump-quick-xml` provides a derive macro to convert from mysqldump in xml format to struct using quick-xml.
3
4# Installation
5
6Add following dependency to your `Cargo.toml`:
7
8```toml,ignore
9[dependencies]
10mysqldump-quick-xml = "0.1"
11```
12
13# Usage
14
15```rust
16use mysqldump_quick_xml::MysqlDumpQuickXml;
17
18#[derive(Debug, PartialEq, MysqlDumpQuickXml)]
19struct Row {
20    id: String,
21    code: String,
22}
23
24fn main() {
25    let xml = r##"
26<?xml version="1.0"?>
27<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
28<database name="db">
29<table_data name="table1">
30    <row>
31        <field name="id">1</field>
32        <field name="code">sample 1</field>
33    </row>
34    <row>
35        <field name="id">2</field>
36        <field name="code">sample 2</field>
37    </row>
38</table_data>
39</database>
40</mysqldump>
41        "##;
42
43    let rows = Row::from_str(xml);
44
45    assert_eq!(
46        rows,
47        vec![
48            Row {
49                id: "1".into(),
50                code: "sample 1".into()
51            },
52            Row {
53                id: "2".into(),
54                code: "sample 2".into()
55            }
56        ]
57    )
58}
59```
60
61*/
62
63
64pub use mysqldump_quick_xml_derive::*;
65
66pub mod quick_xml {
67    pub mod events {
68        pub use ::quick_xml::events::Event;
69    }
70    pub use ::quick_xml::Reader;
71}
72
73pub trait MysqlDumpQuickXml {
74    fn from_str(str: &str) -> Vec<Self>
75    where
76        Self: std::marker::Sized;
77}