xso-proc: completely overengineer everything for no good reason!
Well, not really, of course. All of this will make sense once we start adding support for fields and non-struct types. Refactoring the code now before we start to add actual member field parsing is much easier. How do I know that this will work out? Well, my crystal ball knows it. Don't believe me? Okay, ChatGPT told me ... Alright alright, I went through the entire process of implementing this feature *twice* at this point and have a pretty good idea of where to draw the abstraction lines so that everything falls neatly into place. You'll have to trust me on this one. (Or, you know, check out old branches in my xmpp-rs repo. That might work, too. `feature/derive-macro-streaming-full` might be a name to look for if you dare.)
This commit is contained in:
parent
bf7816d321
commit
183bef5cf6
10 changed files with 930 additions and 135 deletions
|
|
@ -44,7 +44,7 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown child in attention element.");
|
||||
assert_eq!(message, "Unknown child in Attention element.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "disable-validation"))]
|
||||
|
|
@ -58,7 +58,7 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in attention element.");
|
||||
assert_eq!(message, "Unknown attribute in Attention element.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in blocklist element.");
|
||||
assert_eq!(message, "Unknown attribute in BlocklistRequest element.");
|
||||
|
||||
let result_elem = elem.clone();
|
||||
let error = BlocklistResult::try_from(result_elem).unwrap_err();
|
||||
|
|
@ -208,6 +208,6 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown child in blocklist element.");
|
||||
assert_eq!(message, "Unknown child in BlocklistRequest element.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown child in ping element.");
|
||||
assert_eq!(message, "Unknown child in Ping element.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "disable-validation"))]
|
||||
|
|
@ -66,6 +66,6 @@ mod tests {
|
|||
FromElementError::Invalid(Error::Other(string)) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in ping element.");
|
||||
assert_eq!(message, "Unknown attribute in Ping element.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ fn empty_unexpected_attribute() {
|
|||
};
|
||||
match parse_str::<Empty>("<foo xmlns='urn:example:ns1' fnord='bar'/>") {
|
||||
Err(xso::error::FromElementError::Invalid(xso::error::Error::Other(e))) => {
|
||||
assert_eq!(e, "Unknown attribute in foo element.");
|
||||
assert_eq!(e, "Unknown attribute in Empty element.");
|
||||
}
|
||||
other => panic!("unexpected result: {:?}", other),
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ fn empty_unexpected_child() {
|
|||
};
|
||||
match parse_str::<Empty>("<foo xmlns='urn:example:ns1'><coucou/></foo>") {
|
||||
Err(xso::error::FromElementError::Invalid(xso::error::Error::Other(e))) => {
|
||||
assert_eq!(e, "Unknown child in foo element.");
|
||||
assert_eq!(e, "Unknown child in Empty element.");
|
||||
}
|
||||
other => panic!("unexpected result: {:?}", other),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue