Rename namespace to ns in attributes
This more closely mimics the way xmlns gets used in XML in addition to being more concise.
This commit is contained in:
parent
dee065cd9a
commit
25089014fb
|
@ -95,7 +95,7 @@ impl ContainerMeta {
|
||||||
let mut meta = ContainerMeta::default();
|
let mut meta = ContainerMeta::default();
|
||||||
for item in meta_items(&input.attrs) {
|
for item in meta_items(&input.attrs) {
|
||||||
match item {
|
match item {
|
||||||
Meta::List(list) if list.path.is_ident("namespace") => {
|
Meta::List(list) if list.path.is_ident("ns") => {
|
||||||
meta.ns = NamespaceMeta::from_list(&list.nested)
|
meta.ns = NamespaceMeta::from_list(&list.nested)
|
||||||
}
|
}
|
||||||
_ => panic!("invalid xml attribute syntax"),
|
_ => panic!("invalid xml attribute syntax"),
|
||||||
|
@ -117,7 +117,7 @@ impl FieldMeta {
|
||||||
for item in meta_items(&input.attrs) {
|
for item in meta_items(&input.attrs) {
|
||||||
match item {
|
match item {
|
||||||
Meta::Path(path) if path.is_ident("attribute") => meta.attribute = true,
|
Meta::Path(path) if path.is_ident("attribute") => meta.attribute = true,
|
||||||
Meta::List(list) if list.path.is_ident("namespace") => {
|
Meta::List(list) if list.path.is_ident("ns") => {
|
||||||
meta.ns = NamespaceMeta::from_list(&list.nested)
|
meta.ns = NamespaceMeta::from_list(&list.nested)
|
||||||
}
|
}
|
||||||
_ => panic!("invalid xml attribute syntax"),
|
_ => panic!("invalid xml attribute syntax"),
|
||||||
|
|
|
@ -12,12 +12,12 @@ fn unit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, ToXml)]
|
#[derive(Debug, Eq, PartialEq, ToXml)]
|
||||||
#[xml(namespace(bar = "BAZ", foo = "BAR"))]
|
#[xml(ns(bar = "BAZ", foo = "BAR"))]
|
||||||
struct StructWithNamedFields {
|
struct StructWithNamedFields {
|
||||||
flag: bool,
|
flag: bool,
|
||||||
#[xml(namespace(bar))]
|
#[xml(ns(bar))]
|
||||||
string: String,
|
string: String,
|
||||||
#[xml(namespace("typo"))]
|
#[xml(ns("typo"))]
|
||||||
number: i32,
|
number: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,24 +41,24 @@ fn struct_with_named_fields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, ToXml)]
|
#[derive(Debug, Eq, PartialEq, ToXml)]
|
||||||
#[xml(namespace("URI", dar = "BAZ", internal = "INTERNAL"))]
|
#[xml(ns("URI", dar = "BAZ", internal = "INTERNAL"))]
|
||||||
struct Nested {
|
struct Nested {
|
||||||
#[xml(namespace(dar))]
|
#[xml(ns(dar))]
|
||||||
flag_parent_prefix: bool,
|
flag_parent_prefix: bool,
|
||||||
#[xml(namespace(internal))]
|
#[xml(ns(internal))]
|
||||||
flag_internal_prefix: bool,
|
flag_internal_prefix: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, ToXml)]
|
#[derive(Debug, Eq, PartialEq, ToXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ", foo = "BAR"))]
|
#[xml(ns("URI", bar = "BAZ", foo = "BAR"))]
|
||||||
struct StructWithCustomField {
|
struct StructWithCustomField {
|
||||||
#[xml(attribute)]
|
#[xml(attribute)]
|
||||||
int_attribute: i32,
|
int_attribute: i32,
|
||||||
#[xml(namespace("BAZ"))]
|
#[xml(ns("BAZ"))]
|
||||||
flag_direct_namespace_same_the_same_as_prefix: bool,
|
flag_direct_namespace_same_the_same_as_prefix: bool,
|
||||||
#[xml(namespace(bar))]
|
#[xml(ns(bar))]
|
||||||
flag_prefix: bool,
|
flag_prefix: bool,
|
||||||
#[xml(namespace("DIFFERENT"))]
|
#[xml(ns("DIFFERENT"))]
|
||||||
flag_direct_namespace: bool,
|
flag_direct_namespace: bool,
|
||||||
test: Nested,
|
test: Nested,
|
||||||
}
|
}
|
||||||
|
@ -92,16 +92,16 @@ fn struct_with_custom_field() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, ToXml)]
|
#[derive(Debug, Eq, PartialEq, ToXml)]
|
||||||
#[xml(namespace(dar = "BAZ", internal = "INTERNAL"))]
|
#[xml(ns(dar = "BAZ", internal = "INTERNAL"))]
|
||||||
struct NestedDifferentNamespace {
|
struct NestedDifferentNamespace {
|
||||||
#[xml(namespace(dar))]
|
#[xml(ns(dar))]
|
||||||
flag_parent_prefix: bool,
|
flag_parent_prefix: bool,
|
||||||
#[xml(namespace(internal))]
|
#[xml(ns(internal))]
|
||||||
flag_internal_prefix: bool,
|
flag_internal_prefix: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, ToXml)]
|
#[derive(Debug, Eq, PartialEq, ToXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ", foo = "BAR"))]
|
#[xml(ns("URI", bar = "BAZ", foo = "BAR"))]
|
||||||
struct StructChildNamespaces {
|
struct StructChildNamespaces {
|
||||||
different_child_namespace: NestedDifferentNamespace,
|
different_child_namespace: NestedDifferentNamespace,
|
||||||
same_child_namespace: Nested,
|
same_child_namespace: Nested,
|
||||||
|
@ -130,16 +130,16 @@ fn struct_child_namespaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ"))]
|
#[xml(ns("URI", bar = "BAZ"))]
|
||||||
struct NestedDe {
|
struct NestedDe {
|
||||||
#[xml(namespace(bar))]
|
#[xml(ns(bar))]
|
||||||
flag: bool,
|
flag: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ", foo = "BAR"))]
|
#[xml(ns("URI", bar = "BAZ", foo = "BAR"))]
|
||||||
struct StructWithCustomFieldFromXml {
|
struct StructWithCustomFieldFromXml {
|
||||||
#[xml(namespace(bar))]
|
#[xml(ns(bar))]
|
||||||
flag: bool,
|
flag: bool,
|
||||||
#[xml(attribute)]
|
#[xml(attribute)]
|
||||||
flag_attribute: bool,
|
flag_attribute: bool,
|
||||||
|
@ -191,13 +191,13 @@ struct NestedWrongNamespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ"))]
|
#[xml(ns("URI", bar = "BAZ"))]
|
||||||
struct StructWithCorrectNestedNamespace {
|
struct StructWithCorrectNestedNamespace {
|
||||||
test: NestedDe,
|
test: NestedDe,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ"))]
|
#[xml(ns("URI", bar = "BAZ"))]
|
||||||
struct StructWithWrongNestedNamespace {
|
struct StructWithWrongNestedNamespace {
|
||||||
test: NestedWrongNamespace,
|
test: NestedWrongNamespace,
|
||||||
}
|
}
|
||||||
|
@ -256,14 +256,14 @@ fn default_namespaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ"))]
|
#[xml(ns("URI", bar = "BAZ"))]
|
||||||
struct NestedOtherNamespace {
|
struct NestedOtherNamespace {
|
||||||
#[xml(namespace(bar))]
|
#[xml(ns(bar))]
|
||||||
flag: bool,
|
flag: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI", bar = "BAZ"))]
|
#[xml(ns("URI", bar = "BAZ"))]
|
||||||
struct StructOtherNamespace {
|
struct StructOtherNamespace {
|
||||||
test: NestedOtherNamespace,
|
test: NestedOtherNamespace,
|
||||||
}
|
}
|
||||||
|
@ -343,9 +343,9 @@ fn other_namespaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, FromXml)]
|
#[derive(Debug, Eq, PartialEq, FromXml)]
|
||||||
#[xml(namespace("URI"))]
|
#[xml(ns("URI"))]
|
||||||
struct StructDirectNamespace {
|
struct StructDirectNamespace {
|
||||||
#[xml(namespace("BAZ"))]
|
#[xml(ns("BAZ"))]
|
||||||
flag: bool,
|
flag: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,14 +380,14 @@ fn direct_namespaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, FromXml, ToXml)]
|
#[derive(Debug, PartialEq, Eq, FromXml, ToXml)]
|
||||||
#[xml(namespace("URI"))]
|
#[xml(ns("URI"))]
|
||||||
struct NestedLifetimes<'a> {
|
struct NestedLifetimes<'a> {
|
||||||
flag: bool,
|
flag: bool,
|
||||||
str_type_a: &'a str,
|
str_type_a: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, FromXml, ToXml)]
|
#[derive(Debug, PartialEq, FromXml, ToXml)]
|
||||||
#[xml(namespace("URI"))]
|
#[xml(ns("URI"))]
|
||||||
struct StructDeserializerScalars<'a, 'b> {
|
struct StructDeserializerScalars<'a, 'b> {
|
||||||
bool_type: bool,
|
bool_type: bool,
|
||||||
i8_type: i8,
|
i8_type: i8,
|
||||||
|
@ -452,7 +452,7 @@ fn scalars() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, FromXml, ToXml)]
|
#[derive(Debug, PartialEq, Eq, FromXml, ToXml)]
|
||||||
#[xml(namespace("URI"))]
|
#[xml(ns("URI"))]
|
||||||
struct StructSpecialEntities<'a> {
|
struct StructSpecialEntities<'a> {
|
||||||
string: String,
|
string: String,
|
||||||
str: &'a str,
|
str: &'a str,
|
||||||
|
|
Loading…
Reference in New Issue