From 998bf4ca695182404cf6bd2a471c760c33cb1f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sat, 14 Sep 2024 16:26:01 -0300 Subject: [PATCH 1/4] xsd-types: Add clone to struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- xsd-types/src/types/date.rs | 4 ++-- xsd-types/src/types/datetime.rs | 4 ++-- xsd-types/src/types/datetimestamp.rs | 4 ++-- xsd-types/src/types/decimal.rs | 4 ++-- xsd-types/src/types/duration.rs | 2 +- xsd-types/src/types/gday.rs | 4 ++-- xsd-types/src/types/gmonth.rs | 4 ++-- xsd-types/src/types/gmonthday.rs | 4 ++-- xsd-types/src/types/gyear.rs | 4 ++-- xsd-types/src/types/gyearmonth.rs | 4 ++-- xsd-types/src/types/integer.rs | 4 ++-- xsd-types/src/types/negative_integer.rs | 4 ++-- xsd-types/src/types/non_negative_integer.rs | 4 ++-- xsd-types/src/types/non_positive_integer.rs | 4 ++-- xsd-types/src/types/positive_integer.rs | 4 ++-- xsd-types/src/types/time.rs | 4 ++-- 16 files changed, 31 insertions(+), 31 deletions(-) diff --git a/xsd-types/src/types/date.rs b/xsd-types/src/types/date.rs index 34abc5bb..820f9301 100644 --- a/xsd-types/src/types/date.rs +++ b/xsd-types/src/types/date.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::utils::parse_timezone; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct Date { pub value: NaiveDate, pub timezone: Option, @@ -163,7 +163,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/datetime.rs b/xsd-types/src/types/datetime.rs index 75f71394..5bbddbb3 100644 --- a/xsd-types/src/types/datetime.rs +++ b/xsd-types/src/types/datetime.rs @@ -3,7 +3,7 @@ use std::{fmt, str::FromStr}; use chrono::{format::ParseError, DateTime as CDateTime, FixedOffset}; use xsd_macro_utils::UtilsDefaultSerde; -#[derive(PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, PartialOrd, Debug, Clone, UtilsDefaultSerde)] pub struct DateTime { pub value: CDateTime, } @@ -106,7 +106,7 @@ mod tests { assert_eq!(DateTime { value: dt }.to_string(), "2020-03-07T04:40:00-06:30"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/datetimestamp.rs b/xsd-types/src/types/datetimestamp.rs index 167d7c48..a4bc81fb 100644 --- a/xsd-types/src/types/datetimestamp.rs +++ b/xsd-types/src/types/datetimestamp.rs @@ -6,7 +6,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::datetime::DateTime; // The only difference from DateTime is that the time zone expression is required at the end of the value. -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct DateTimeStamp { pub value: DateTime, } @@ -114,7 +114,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/decimal.rs b/xsd-types/src/types/decimal.rs index b28b2dae..c5fcd6cb 100644 --- a/xsd-types/src/types/decimal.rs +++ b/xsd-types/src/types/decimal.rs @@ -3,7 +3,7 @@ use std::{fmt, str::FromStr}; use bigdecimal::{BigDecimal, ParseBigDecimalError}; use xsd_macro_utils::UtilsDefaultSerde; -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct Decimal(pub BigDecimal); impl Decimal { @@ -38,7 +38,7 @@ mod tests { use super::*; use crate::utils::xml_eq::assert_xml_eq; - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct DecimalPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/duration.rs b/xsd-types/src/types/duration.rs index 8ff29a27..1adcb59e 100644 --- a/xsd-types/src/types/duration.rs +++ b/xsd-types/src/types/duration.rs @@ -2,7 +2,7 @@ use std::{fmt, fmt::Write, str::FromStr}; use xsd_macro_utils::UtilsDefaultSerde; -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct Duration { pub is_negative: bool, diff --git a/xsd-types/src/types/gday.rs b/xsd-types/src/types/gday.rs index e92c9c5d..74fcfe4e 100644 --- a/xsd-types/src/types/gday.rs +++ b/xsd-types/src/types/gday.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::utils::parse_timezone; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct GDay { pub value: i32, pub timezone: Option, @@ -148,7 +148,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/gmonth.rs b/xsd-types/src/types/gmonth.rs index 73008fb6..2ce2ca30 100644 --- a/xsd-types/src/types/gmonth.rs +++ b/xsd-types/src/types/gmonth.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::utils::parse_timezone; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct GMonth { pub value: i32, pub timezone: Option, @@ -148,7 +148,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/gmonthday.rs b/xsd-types/src/types/gmonthday.rs index cf1c70a0..183c96ae 100644 --- a/xsd-types/src/types/gmonthday.rs +++ b/xsd-types/src/types/gmonthday.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::{gday::GDay, gmonth::GMonth, utils::parse_timezone}; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct GMonthDay { pub month: i32, pub day: i32, @@ -199,7 +199,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/gyear.rs b/xsd-types/src/types/gyear.rs index d3475138..7943e8b2 100644 --- a/xsd-types/src/types/gyear.rs +++ b/xsd-types/src/types/gyear.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::utils::parse_timezone; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct GYear { pub value: i32, pub timezone: Option, @@ -208,7 +208,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/gyearmonth.rs b/xsd-types/src/types/gyearmonth.rs index b919d763..38a3a093 100644 --- a/xsd-types/src/types/gyearmonth.rs +++ b/xsd-types/src/types/gyearmonth.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::{gmonth::GMonth, gyear::GYear, utils::parse_timezone}; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct GYearMonth { pub year: i32, pub month: i32, @@ -258,7 +258,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] diff --git a/xsd-types/src/types/integer.rs b/xsd-types/src/types/integer.rs index e26ed50c..610189cb 100644 --- a/xsd-types/src/types/integer.rs +++ b/xsd-types/src/types/integer.rs @@ -4,7 +4,7 @@ use num_bigint::{BigInt, ParseBigIntError, ToBigInt}; use xsd_macro_utils::UtilsDefaultSerde; // https://www.w3.org/TR/xmlschema-2/#integer -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct Integer(pub BigInt); impl Integer { @@ -74,7 +74,7 @@ mod tests { assert_eq!(Integer((-1).to_bigint().unwrap()).to_string(), "-1"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct IntegerPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/negative_integer.rs b/xsd-types/src/types/negative_integer.rs index f9b79a17..009a293f 100644 --- a/xsd-types/src/types/negative_integer.rs +++ b/xsd-types/src/types/negative_integer.rs @@ -4,7 +4,7 @@ use num_bigint::{BigInt, ToBigInt}; use xsd_macro_utils::UtilsDefaultSerde; // https://www.w3.org/TR/xmlschema-2/#negativeInteger -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct NegativeInteger(pub BigInt); impl NegativeInteger { @@ -83,7 +83,7 @@ mod tests { assert_eq!(NegativeInteger((-1).to_bigint().unwrap()).to_string(), "-1"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct NegativeIntegerPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/non_negative_integer.rs b/xsd-types/src/types/non_negative_integer.rs index 58c41616..044781a1 100644 --- a/xsd-types/src/types/non_negative_integer.rs +++ b/xsd-types/src/types/non_negative_integer.rs @@ -4,7 +4,7 @@ use num_bigint::{BigUint, ToBigUint}; use xsd_macro_utils::UtilsDefaultSerde; // https://www.w3.org/TR/xmlschema-2/#nonNegativeInteger -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct NonNegativeInteger(pub BigUint); impl NonNegativeInteger { @@ -83,7 +83,7 @@ mod tests { assert_eq!(NonNegativeInteger(0.to_biguint().unwrap()).to_string(), "0"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct NonNegativeIntegerPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/non_positive_integer.rs b/xsd-types/src/types/non_positive_integer.rs index 3fd1adac..b0565a6b 100644 --- a/xsd-types/src/types/non_positive_integer.rs +++ b/xsd-types/src/types/non_positive_integer.rs @@ -4,7 +4,7 @@ use num_bigint::{BigInt, ToBigInt}; use xsd_macro_utils::UtilsDefaultSerde; // https://www.w3.org/TR/xmlschema-2/#nonPositiveInteger -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct NonPositiveInteger(pub BigInt); impl NonPositiveInteger { @@ -90,7 +90,7 @@ mod tests { assert_eq!(NonPositiveInteger((-1).to_bigint().unwrap()).to_string(), "-1"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct NonPositiveIntegerPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/positive_integer.rs b/xsd-types/src/types/positive_integer.rs index c5164159..ea98080b 100644 --- a/xsd-types/src/types/positive_integer.rs +++ b/xsd-types/src/types/positive_integer.rs @@ -4,7 +4,7 @@ use num_bigint::{BigUint, ToBigUint}; use xsd_macro_utils::UtilsDefaultSerde; // https://www.w3.org/TR/xmlschema-2/#positiveInteger -#[derive(Default, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, PartialOrd, Debug, UtilsDefaultSerde)] pub struct PositiveInteger(pub BigUint); impl PositiveInteger { @@ -79,7 +79,7 @@ mod tests { assert_eq!(PositiveInteger(100000.to_biguint().unwrap()).to_string(), "100000"); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct PositiveIntegerPair { #[yaserde(prefix = "t", rename = "First")] diff --git a/xsd-types/src/types/time.rs b/xsd-types/src/types/time.rs index f752b0f3..baa2d26a 100644 --- a/xsd-types/src/types/time.rs +++ b/xsd-types/src/types/time.rs @@ -5,7 +5,7 @@ use xsd_macro_utils::UtilsDefaultSerde; use crate::types::utils::parse_timezone; -#[derive(PartialEq, Debug, UtilsDefaultSerde)] +#[derive(PartialEq, Debug, Clone, UtilsDefaultSerde)] pub struct Time { pub value: NaiveTime, pub timezone: Option, @@ -166,7 +166,7 @@ mod tests { ); } - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "t", namespace = "t: test")] pub struct Message { #[yaserde(prefix = "t", rename = "CreatedAt")] From ae443f32d5283786c9c621c677b5879816103833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sat, 14 Sep 2024 16:26:37 -0300 Subject: [PATCH 2/4] xsd-parser: Add clone to struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- xsd-parser/src/generator/mod.rs | 3 ++- xsd-parser/src/generator/struct.rs | 2 +- xsd-parser/src/generator/tuple_struct.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xsd-parser/src/generator/mod.rs b/xsd-parser/src/generator/mod.rs index 8b2fb719..c9863c1d 100644 --- a/xsd-parser/src/generator/mod.rs +++ b/xsd-parser/src/generator/mod.rs @@ -92,7 +92,8 @@ mod test { ..Default::default() })); let comment = "// comment\n"; - let macros = "#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n"; + let macros = + "#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n"; let validation = "impl Validate for Name {}\n"; let expected = format!("{}{}pub struct Name (pub Type);\n\n{}", comment, macros, validation); diff --git a/xsd-parser/src/generator/struct.rs b/xsd-parser/src/generator/struct.rs index f6a641a6..af015134 100644 --- a/xsd-parser/src/generator/struct.rs +++ b/xsd-parser/src/generator/struct.rs @@ -79,7 +79,7 @@ pub trait StructGenerator { } fn macros(&self, _entity: &Struct, gen: &Generator) -> Cow<'static, str> { - let derives = "#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]\n"; + let derives = "#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]\n"; let tns = gen.target_ns.borrow(); match tns.as_ref() { Some(tn) => match tn.name() { diff --git a/xsd-parser/src/generator/tuple_struct.rs b/xsd-parser/src/generator/tuple_struct.rs index 6e5496f3..c340ecaf 100644 --- a/xsd-parser/src/generator/tuple_struct.rs +++ b/xsd-parser/src/generator/tuple_struct.rs @@ -39,7 +39,7 @@ pub trait TupleStructGenerator { } fn macros(&self, _entity: &TupleStruct, _gen: &Generator) -> Cow<'static, str> { - "#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n".into() + "#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n".into() } fn format_comment(&self, entity: &TupleStruct, gen: &Generator) -> String { From 3a33133c6ec79510ad435b07be55b6ee4a516b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sat, 14 Sep 2024 16:27:01 -0300 Subject: [PATCH 3/4] README: Update info with Clone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b445e48..99a2e155 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ There are cases when schema allows extensions for the certain type. In such cases we don't know in advance what fields must be present in Rust struct so we don't add them to output: ```rust -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct MyType { #[yaserde(prefix = "tns", rename = "Parameters")] From 075f6b045d96d21112e17a828ae5e1264151064f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Thu, 19 Sep 2024 10:15:35 -0300 Subject: [PATCH 4/4] Update tests with clone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- wsdl-parser/tests/port_type_to_function/expected.rs | 4 ++-- xsd-parser/src/generator/enum.rs | 2 +- xsd-parser/tests/all/expected.rs | 2 +- xsd-parser/tests/any/expected.rs | 2 +- xsd-parser/tests/choice/expected.rs | 8 ++++---- xsd-parser/tests/complex_type/expected.rs | 2 +- xsd-parser/tests/complex_type_subtypes_clash/expected.rs | 8 ++++---- xsd-parser/tests/enumeration/expected.rs | 4 ++-- xsd-parser/tests/extension_base/expected.rs | 4 ++-- xsd-parser/tests/extension_base_multilayer/expected.rs | 6 +++--- xsd-parser/tests/extension_base_two_files/expected.rs | 2 +- xsd-parser/tests/ref_to_attribute/expected.rs | 4 ++-- xsd-parser/tests/rename_only_where_needed/expected.rs | 2 +- xsd-parser/tests/restriction_any_type/expected.rs | 2 +- xsd-parser/tests/simple_type/expected.rs | 2 +- xsd-parser/tests/tuple_with_integer/expected.rs | 2 +- xsd-parser/tests/tuple_with_string/expected.rs | 2 +- xsd-parser/tests/tuple_with_vec/expected.rs | 2 +- xsd-parser/tests/type_name_clash/expected.rs | 6 +++--- xsd-parser/tests/xsd_string/expected.rs | 2 +- 20 files changed, 34 insertions(+), 34 deletions(-) diff --git a/wsdl-parser/tests/port_type_to_function/expected.rs b/wsdl-parser/tests/port_type_to_function/expected.rs index 7b857c33..41a9bf90 100644 --- a/wsdl-parser/tests/port_type_to_function/expected.rs +++ b/wsdl-parser/tests/port_type_to_function/expected.rs @@ -1,5 +1,5 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tds", namespace = "tds: http://www.onvif.org/ver10/device/wsdl")] pub struct GetServices { // Indicates if the service capabilities (untyped) should be included in the @@ -11,7 +11,7 @@ pub struct GetServices { impl Validate for GetServices {} -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tds", namespace = "tds: http://www.onvif.org/ver10/device/wsdl")] pub struct GetServicesResponse { // Each Service element contains information about one service. diff --git a/xsd-parser/src/generator/enum.rs b/xsd-parser/src/generator/enum.rs index d314e72d..449d1b7e 100644 --- a/xsd-parser/src/generator/enum.rs +++ b/xsd-parser/src/generator/enum.rs @@ -65,7 +65,7 @@ pub trait EnumGenerator { return "#[derive(PartialEq, Debug, UtilsUnionSerDe)]".into(); } - let derives = "#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]"; + let derives = "#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]"; let tns = gen.target_ns.borrow(); match tns.as_ref() { Some(tn) => match tn.name() { diff --git a/xsd-parser/tests/all/expected.rs b/xsd-parser/tests/all/expected.rs index 4534a17a..97064988 100644 --- a/xsd-parser/tests/all/expected.rs +++ b/xsd-parser/tests/all/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Once")] diff --git a/xsd-parser/tests/any/expected.rs b/xsd-parser/tests/any/expected.rs index f568b7ff..62e249a9 100644 --- a/xsd-parser/tests/any/expected.rs +++ b/xsd-parser/tests/any/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Name")] diff --git a/xsd-parser/tests/choice/expected.rs b/xsd-parser/tests/choice/expected.rs index 325a8d7f..4d35757f 100644 --- a/xsd-parser/tests/choice/expected.rs +++ b/xsd-parser/tests/choice/expected.rs @@ -1,10 +1,10 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct BarType(pub String); -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct BazType(pub i32); -#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub enum FooTypeChoice { Bar(BarType), @@ -18,7 +18,7 @@ impl Default for FooTypeChoice { } } -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(flatten)] diff --git a/xsd-parser/tests/complex_type/expected.rs b/xsd-parser/tests/complex_type/expected.rs index 137a06ad..887808fc 100644 --- a/xsd-parser/tests/complex_type/expected.rs +++ b/xsd-parser/tests/complex_type/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Min")] diff --git a/xsd-parser/tests/complex_type_subtypes_clash/expected.rs b/xsd-parser/tests/complex_type_subtypes_clash/expected.rs index 1dfd0e25..5cacde00 100644 --- a/xsd-parser/tests/complex_type_subtypes_clash/expected.rs +++ b/xsd-parser/tests/complex_type_subtypes_clash/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Extension")] @@ -10,14 +10,14 @@ impl Validate for FooType {} pub mod foo_type { use super::*; - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct ExtensionType {} impl Validate for ExtensionType {} } -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(prefix = "tns", rename = "Extension")] @@ -29,7 +29,7 @@ impl Validate for BarType {} pub mod bar_type { use super::*; - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct ExtensionType {} diff --git a/xsd-parser/tests/enumeration/expected.rs b/xsd-parser/tests/enumeration/expected.rs index c74af0e3..e27fb074 100644 --- a/xsd-parser/tests/enumeration/expected.rs +++ b/xsd-parser/tests/enumeration/expected.rs @@ -1,4 +1,4 @@ -#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub enum FooType { #[yaserde(rename = "OFF")] @@ -18,7 +18,7 @@ impl Default for FooType { impl Validate for FooType {} -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct FooType2(pub String); impl Validate for FooType2 {} diff --git a/xsd-parser/tests/extension_base/expected.rs b/xsd-parser/tests/extension_base/expected.rs index 8849a9dd..41068414 100644 --- a/xsd-parser/tests/extension_base/expected.rs +++ b/xsd-parser/tests/extension_base/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(prefix = "tns", rename = "b")] @@ -10,7 +10,7 @@ pub struct BarType { impl Validate for BarType {} -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "a")] diff --git a/xsd-parser/tests/extension_base_multilayer/expected.rs b/xsd-parser/tests/extension_base_multilayer/expected.rs index 2bed61c9..b6c13ea6 100644 --- a/xsd-parser/tests/extension_base_multilayer/expected.rs +++ b/xsd-parser/tests/extension_base_multilayer/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(prefix = "tns", rename = "aa")] @@ -10,7 +10,7 @@ pub struct BarType { impl Validate for BarType {} -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Messages")] @@ -22,7 +22,7 @@ impl Validate for FooType {} pub mod foo_type { use super::*; - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct MessagesType { #[yaserde(prefix = "tns", rename = "a")] diff --git a/xsd-parser/tests/extension_base_two_files/expected.rs b/xsd-parser/tests/extension_base_two_files/expected.rs index d6e658a2..800605bc 100644 --- a/xsd-parser/tests/extension_base_two_files/expected.rs +++ b/xsd-parser/tests/extension_base_two_files/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde( prefix = "tns", namespace = "tns: http://example.com", diff --git a/xsd-parser/tests/ref_to_attribute/expected.rs b/xsd-parser/tests/ref_to_attribute/expected.rs index 1093a598..76325321 100644 --- a/xsd-parser/tests/ref_to_attribute/expected.rs +++ b/xsd-parser/tests/ref_to_attribute/expected.rs @@ -1,8 +1,8 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct Id(pub String); impl Validate for Id {} -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(attribute, prefix = "tns", rename = "id")] diff --git a/xsd-parser/tests/rename_only_where_needed/expected.rs b/xsd-parser/tests/rename_only_where_needed/expected.rs index dba0e4a9..4c2d3f5a 100644 --- a/xsd-parser/tests/rename_only_where_needed/expected.rs +++ b/xsd-parser/tests/rename_only_where_needed/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns")] diff --git a/xsd-parser/tests/restriction_any_type/expected.rs b/xsd-parser/tests/restriction_any_type/expected.rs index efa1be41..fc6aaf80 100644 --- a/xsd-parser/tests/restriction_any_type/expected.rs +++ b/xsd-parser/tests/restriction_any_type/expected.rs @@ -1,5 +1,5 @@ // pub type AppSequence = AppSequenceType; -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://schemas.xmlsoap.org/ws/2005/04/discovery")] pub struct AppSequenceType { #[yaserde(attribute, rename = "InstanceId")] diff --git a/xsd-parser/tests/simple_type/expected.rs b/xsd-parser/tests/simple_type/expected.rs index a67851b5..44ecaf94 100644 --- a/xsd-parser/tests/simple_type/expected.rs +++ b/xsd-parser/tests/simple_type/expected.rs @@ -1,2 +1,2 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct FooType (pub String); diff --git a/xsd-parser/tests/tuple_with_integer/expected.rs b/xsd-parser/tests/tuple_with_integer/expected.rs index 2e78b1cf..8a6fd500 100644 --- a/xsd-parser/tests/tuple_with_integer/expected.rs +++ b/xsd-parser/tests/tuple_with_integer/expected.rs @@ -1,2 +1,2 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct FooType (pub Integer); diff --git a/xsd-parser/tests/tuple_with_string/expected.rs b/xsd-parser/tests/tuple_with_string/expected.rs index ef82ccf1..89a59481 100644 --- a/xsd-parser/tests/tuple_with_string/expected.rs +++ b/xsd-parser/tests/tuple_with_string/expected.rs @@ -1,2 +1,2 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct FooType(pub String); diff --git a/xsd-parser/tests/tuple_with_vec/expected.rs b/xsd-parser/tests/tuple_with_vec/expected.rs index d7968913..c25fa971 100644 --- a/xsd-parser/tests/tuple_with_vec/expected.rs +++ b/xsd-parser/tests/tuple_with_vec/expected.rs @@ -1,2 +1,2 @@ -#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct FooType(pub Vec); diff --git a/xsd-parser/tests/type_name_clash/expected.rs b/xsd-parser/tests/type_name_clash/expected.rs index d24d8322..076e214e 100644 --- a/xsd-parser/tests/type_name_clash/expected.rs +++ b/xsd-parser/tests/type_name_clash/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(attribute, rename = "a")] @@ -8,7 +8,7 @@ pub struct BarType { impl Validate for BarType {} -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Bar")] @@ -20,7 +20,7 @@ impl Validate for FooType {} pub mod foo_type { use super::*; - #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] + #[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(attribute, rename = "b")] diff --git a/xsd-parser/tests/xsd_string/expected.rs b/xsd-parser/tests/xsd_string/expected.rs index d6acd2c4..1d0528c5 100644 --- a/xsd-parser/tests/xsd_string/expected.rs +++ b/xsd-parser/tests/xsd_string/expected.rs @@ -1,4 +1,4 @@ -#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] +#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Text")]