Skip to content

Commit

Permalink
feat: use syn 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcAntoine-Arnaud committed Nov 5, 2024
1 parent ae66b1e commit dbf9e03
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 447 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# yaserde   [![Build Status]][travis] [![Latest Version]][crates.io] [![Coverage Status]][coveralls]
# yaserde   [![Latest Version]][crates.io]

[Build Status]: https://travis-ci.com/media-io/yaserde.svg?branch=master
[travis]: https://travis-ci.com/media-io/yaserde
[Latest Version]: https://img.shields.io/crates/v/yaserde.svg
[crates.io]: https://crates.io/crates/yaserde

[Coverage Status]: https://coveralls.io/repos/github/media-io/yaserde/badge.svg?branch=master
[coveralls]: https://coveralls.io/github/media-io/yaserde?branch=master

**Yet Another Serializer/Deserializer specialized for XML**

## Goal
Expand Down
13 changes: 7 additions & 6 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod bbigras_namespace;
mod boscop;
mod generic;
mod ln_dom;
mod same_element_different_namespaces;
mod svd;
// mod bbigras_namespace;
// mod boscop;
// mod generic;
// mod ln_dom;
// mod same_element_different_namespaces;
// mod svd;
//
10 changes: 4 additions & 6 deletions yaserde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
//! #[derive(PartialEq, Debug, YaSerialize)]
//! #[yaserde(rename = "device")]
//! struct Device {
//! #[yaserde(attribute)]
//! #[yaserde(attribute = true)]
//! schemaversion: String,
//! #[yaserde(attribute)]
//! #[yaserde(attribute = true)]
//! xmlns: String,
//! #[yaserde(attribute)]
//! #[yaserde(attribute = true)]
//! xsnonamespaceschemalocation: String,
//! #[yaserde(child)]
//! attributes: DeviceAttributes
//! }
//!
//! #[derive(PartialEq, Debug, YaSerialize)]
//! struct DeviceAttributes {
//! #[yaserde(child)]
//! vendor: String,
//! }
//!```
Expand Down Expand Up @@ -297,7 +295,7 @@ macro_rules! test_for_attribute_type {
#[derive(Debug, PartialEq, YaDeserialize, YaSerialize)]
#[yaserde(rename = "data")]
pub struct Data {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
item: $type,
}
let model = Data { item: $value };
Expand Down
4 changes: 2 additions & 2 deletions yaserde/tests/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn default_attribute_string() {
#[derive(Debug, PartialEq, YaDeserialize, YaSerialize)]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(attribute, default = "default_string")]
#[yaserde(attribute = true, default = "default_string")]
background: String,
}

Expand All @@ -128,7 +128,7 @@ fn module_inclusion() {
#[derive(Debug, PartialEq, YaDeserialize, YaSerialize)]
#[yaserde(rename = "module")]
pub struct Module {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
pub color: String,
}
}
Expand Down
80 changes: 40 additions & 40 deletions yaserde/tests/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn de_basic() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "book")]
#[yaserde(rename = "book")]
pub struct Book {
author: String,
title: String,
Expand Down Expand Up @@ -59,9 +59,9 @@ fn de_keyword() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "book")]
#[yaserde(rename = "book")]
pub struct Book {
#[yaserde(attribute, rename = "ref")]
#[yaserde(attribute = true, rename = "ref")]
pub r#ref: String,
}

Expand All @@ -80,7 +80,7 @@ fn de_dash_param() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "book")]
#[yaserde(rename = "book")]
pub struct Book {
#[yaserde(rename = "author-release")]
author: String,
Expand Down Expand Up @@ -123,7 +123,7 @@ fn de_multiple_segments() {
}

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "book")]
#[yaserde(rename = "book")]
pub struct Book {
author: String,
title: String,
Expand Down Expand Up @@ -160,7 +160,7 @@ fn de_list_of_items() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "library")]
#[yaserde(rename = "library")]
pub struct Library {
books: Vec<String>,
}
Expand All @@ -175,7 +175,7 @@ fn de_list_of_items() {
);

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "libraries")]
#[yaserde(rename = "libraries")]
pub struct Libraries {
library: Vec<Library>,
}
Expand All @@ -202,17 +202,17 @@ fn de_attributes() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
item: String,
sub: SubStruct,
}

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "sub")]
#[yaserde(rename = "sub")]
pub struct SubStruct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
subitem: String,
}

Expand Down Expand Up @@ -268,9 +268,9 @@ fn de_attributes_custom_deserializer() {

#[derive(YaDeserialize, PartialEq, Debug)]
pub struct Struct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
attr_option_string: Option<String>,
#[yaserde(attribute)]
#[yaserde(attribute = true)]
attr_option_struct: Option<other_mod::Attributes>,
}

Expand Down Expand Up @@ -312,9 +312,9 @@ fn de_attributes_complex() {

#[derive(YaDeserialize, PartialEq, Debug)]
pub struct Struct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
attr_option_string: Option<String>,
#[yaserde(attribute)]
#[yaserde(attribute = true)]
attr_option_enum: Option<other_mod::AttrEnum>,
}

Expand Down Expand Up @@ -343,7 +343,7 @@ fn de_attributes_with_same_name_field() {

#[derive(YaDeserialize, PartialEq, Debug)]
pub struct Struct {
#[yaserde(attribute, rename = "content")]
#[yaserde(attribute = true, rename = "content")]
attribute: Option<String>,
content: Option<String>,
}
Expand Down Expand Up @@ -381,9 +381,9 @@ fn de_rename() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(attribute, rename = "Item")]
#[yaserde(attribute = true, rename = "Item")]
item: String,
#[yaserde(rename = "sub")]
sub_struct: SubStruct,
Expand All @@ -392,9 +392,9 @@ fn de_rename() {
}

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "sub")]
#[yaserde(rename = "sub")]
pub struct SubStruct {
#[yaserde(attribute, rename = "sub_item")]
#[yaserde(attribute = true, rename = "sub_item")]
subitem: String,
}

Expand All @@ -417,20 +417,20 @@ fn de_text_content_with_attributes() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(attribute, rename = "Item")]
#[yaserde(attribute = true, rename = "Item")]
item: String,
#[yaserde(rename = "sub")]
sub_struct: SubStruct,
}

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "sub")]
#[yaserde(rename = "sub")]
pub struct SubStruct {
#[yaserde(attribute, rename = "sub_item")]
#[yaserde(attribute = true, rename = "sub_item")]
subitem: String,
#[yaserde(text)]
#[yaserde(text = true)]
text: String,
}

Expand All @@ -454,7 +454,7 @@ fn de_text_attribute_on_optional_string() {
#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(text)]
#[yaserde(text = true)]
text: Option<String>,
}

Expand All @@ -474,19 +474,19 @@ fn de_enum() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct XmlStruct {
background: Color,
}

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct Colors {
items: Vec<Color>,
}

#[derive(Default, YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "color")]
#[yaserde(rename = "color")]
pub enum Color {
#[default]
White,
Expand Down Expand Up @@ -525,14 +525,14 @@ fn de_attribute_enum() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "base")]
#[yaserde(rename = "base")]
pub struct XmlStruct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
background: Color,
}

#[derive(Default, YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "color")]
#[yaserde(rename = "color")]
pub enum Color {
#[default]
White,
Expand Down Expand Up @@ -770,7 +770,7 @@ fn de_name_issue_21() {
init();

#[derive(YaDeserialize, PartialEq, Debug)]
#[yaserde(root = "book")]
#[yaserde(rename = "book")]
pub struct Book {
name: String,
}
Expand Down Expand Up @@ -906,7 +906,7 @@ fn de_subitem_issue_12_attributes() {

#[derive(PartialEq, Debug, YaDeserialize)]
pub struct Struct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
id: i32,
}

Expand All @@ -927,13 +927,13 @@ fn de_subitem_issue_12_attributes_with_sub() {

#[derive(PartialEq, Debug, YaDeserialize)]
pub struct SubStruct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
id: i32,
}

#[derive(PartialEq, Debug, YaDeserialize)]
pub struct Struct {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
id: i32,
sub1: SubStruct,
sub2: SubStruct,
Expand Down Expand Up @@ -1082,11 +1082,11 @@ fn de_attribute_sequence() {

#[derive(Debug, PartialEq, YaDeserialize)]
pub struct Outer {
#[yaserde(attribute, rename = "seq1")]
#[yaserde(attribute = true, rename = "seq1")]
seq1: Vec<i32>,
#[yaserde(child, attribute, rename = "seq2")]
#[yaserde(attribute = true, rename = "seq2")]
seq2: Vec<Inner>,
#[yaserde(attribute, rename = "seq3")]
#[yaserde(attribute = true, rename = "seq3")]
seq3: Vec<String>,
}

Expand All @@ -1109,7 +1109,7 @@ fn de_nested_macro_rules() {
($type:ty) => {
#[derive(PartialEq, Debug, YaDeserialize)]
pub struct Outer {
#[yaserde(attribute)]
#[yaserde(attribute = true)]
pub inner: Option<$type>,
}
};
Expand Down
Loading

0 comments on commit dbf9e03

Please sign in to comment.