minidom: Rework Prefixes internal structure
Change the mapping in Prefixes to Prefix -> Namespace instead of Namespace -> Prefix. This allows us to not have duplicate prefixes anymore, but requires us to store the prefix on Element. This prefix is only taken as a hint anyway and used only when coming from the reader. This commits also partially removes the possibility to add prefixes when creating an Element via `Element::new`, `Element::builder` or `Element::bare`. Proper errors should be added in the following commits. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
429949102d
commit
1f2d7aa99d
4 changed files with 106 additions and 93 deletions
|
|
@ -35,6 +35,10 @@ pub enum Error {
|
|||
/// An error which is returned when an elemet's name contains more than one colon
|
||||
InvalidElement,
|
||||
|
||||
/// An error which is returned when an element being serialized doesn't contain a prefix
|
||||
/// (be it None or Some(_)).
|
||||
InvalidPrefix,
|
||||
|
||||
/// An error which is returned when an element doesn't contain a namespace
|
||||
MissingNamespace,
|
||||
|
||||
|
|
@ -51,6 +55,7 @@ impl StdError for Error {
|
|||
Error::EndOfDocument => None,
|
||||
Error::InvalidElementClosed => None,
|
||||
Error::InvalidElement => None,
|
||||
Error::InvalidPrefix => None,
|
||||
Error::MissingNamespace => None,
|
||||
Error::NoComments => None,
|
||||
}
|
||||
|
|
@ -70,6 +75,7 @@ impl std::fmt::Display for Error {
|
|||
write!(fmt, "the XML is invalid, an element was wrongly closed")
|
||||
}
|
||||
Error::InvalidElement => write!(fmt, "the XML element is invalid"),
|
||||
Error::InvalidPrefix => write!(fmt, "the prefix is invalid"),
|
||||
Error::MissingNamespace => write!(
|
||||
fmt,
|
||||
"the XML element is missing a namespace",
|
||||
|
|
|
|||
Loading…
Reference in a new issue