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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
/*! Crate `mysqldump-quick-xml` provides a derive macro to convert from mysqldump in xml format to struct using quick-xml. # Installation Add following dependency to your `Cargo.toml`: ```toml,ignore [dependencies] mysqldump-quick-xml = "0.1" ``` # Usage ```rust use mysqldump_quick_xml::MysqlDumpQuickXml; #[derive(Debug, PartialEq, MysqlDumpQuickXml)] struct Row { id: String, code: String, } fn main() { let xml = r##" <?xml version="1.0"?> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="db"> <table_data name="table1"> <row> <field name="id">1</field> <field name="code">sample 1</field> </row> <row> <field name="id">2</field> <field name="code">sample 2</field> </row> </table_data> </database> </mysqldump> "##; let rows = Row::from_str(xml); assert_eq!( rows, vec![ Row { id: "1".into(), code: "sample 1".into() }, Row { id: "2".into(), code: "sample 2".into() } ] ) } ``` */ pub use mysqldump_quick_xml_derive::*; pub mod quick_xml { pub mod events { pub use ::quick_xml::events::Event; } pub use ::quick_xml::Reader; } pub trait MysqlDumpQuickXml { fn from_str(str: &str) -> Vec<Self> where Self: std::marker::Sized; }