Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 39 variants InvalidXmlPrefixUri(TextPos), UnexpectedXmlUri(TextPos), UnexpectedXmlnsUri(TextPos), InvalidElementNamePrefix(TextPos), DuplicatedNamespace(String, TextPos), UnknownNamespace(String, TextPos), UnexpectedCloseTag { expected: String, actual: String, pos: TextPos, }, UnknownEntityReference(String, TextPos), MalformedEntityReference(TextPos), DuplicatedAttribute(String, TextPos), NoRootNode, UnclosedRootNode, UnexpectedDeclaration(TextPos), DtdDetected, NodesLimitReached, AttributesLimitReached, NamespacesLimitReached, InvalidName(TextPos), NonXmlChar(char, TextPos), InvalidChar { expected: u8, actual: u8, pos: TextPos, }, ExpectedChar { expected: &'static str, actual: u8, pos: TextPos, }, InvalidString(&'static str, TextPos), InvalidComment(TextPos), InvalidCharacterData(TextPos), UnknownToken(TextPos), UnexpectedEndOfStream, InvalidCharacterReference(TextPos), InvalidPiTarget(TextPos), PiWithoutWhitespace(TextPos), InvalidXmlDeclaration(&'static str, TextPos), InvalidQName(TextPos), EmptyPrefixedNamespace(String, TextPos), XmlnsPrefixDeclared(TextPos), DuplicatedNamespaceDeclaration(String, TextPos), PrefixedXmlnsAttribute(String, TextPos), DepthLimitReached, UnsupportedEncoding(String), EncodingMismatch { found: &'static str, declared: String, }, InvalidEncodedBytes { encoding: &'static str, pos: TextPos, },
}
Expand description

Why a text is not a document the reader accepts.

The variants before Error::InvalidCharacterReference are reported for the same documents, at the same positions and with the same messages as the roxmltree crate (version 0.21, with document type declarations refused) reports them. The variants from Error::InvalidCharacterReference on are for documents that roxmltree accepts although they are not well-formed (XML 1.0) or not namespace-well-formed (Namespaces in XML 1.0), and for the limits that it does not have; the crate documentation lists them.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidXmlPrefixUri(TextPos)

xmlns:xml declares a namespace other than http://www.w3.org/XML/1998/namespace.

§

UnexpectedXmlUri(TextPos)

The http://www.w3.org/XML/1998/namespace namespace is declared for a prefix other than xml, or as the default namespace.

§

UnexpectedXmlnsUri(TextPos)

The http://www.w3.org/2000/xmlns/ namespace is declared.

§

InvalidElementNamePrefix(TextPos)

An element name with the xmlns prefix.

§

DuplicatedNamespace(String, TextPos)

The same prefix is declared twice on an element.

§

UnknownNamespace(String, TextPos)

An element or attribute name whose prefix is not declared (the prefix).

§

UnexpectedCloseTag

An end tag that does not match the open element.

Fields

§expected: String

The name of the open element, as written.

§actual: String

The name in the end tag.

§pos: TextPos

Where the end tag starts.

§

UnknownEntityReference(String, TextPos)

A reference to an entity other than the five predefined ones (its name).

§

MalformedEntityReference(TextPos)

An & that does not start a well-formed reference to an XML character.

§

DuplicatedAttribute(String, TextPos)

Two attributes of an element with the same expanded name (the local name).

§

NoRootNode

No element.

§

UnclosedRootNode

The text ends before the document element is closed.

§

UnexpectedDeclaration(TextPos)

An XML declaration elsewhere than at the start of the text.

§

DtdDetected

A document type declaration: refused, because its entities and attribute defaults could change the document.

§

NodesLimitReached

More nodes than crate::Limits::nodes.

§

AttributesLimitReached

More attributes than crate::Limits::attributes.

§

NamespacesLimitReached

More distinct namespace declarations than crate::Limits::namespaces.

§

InvalidName(TextPos)

A name that is not a name.

§

NonXmlChar(char, TextPos)

A character that XML does not allow.

§

InvalidChar

A byte other than the one expected.

Fields

§expected: u8

The byte expected.

§actual: u8

The byte found.

§pos: TextPos

Where.

§

ExpectedChar

A byte other than one of a class expected (described in words).

Fields

§expected: &'static str

What was expected.

§actual: u8

The byte found.

§pos: TextPos

Where.

§

InvalidString(&'static str, TextPos)

The string expected is missing.

§

InvalidComment(TextPos)

A comment that contains -- or ends with - (the position of the comment).

§

InvalidCharacterData(TextPos)

]]> in character data (the position of the end of the text).

§

UnknownToken(TextPos)

Something that is not markup where markup is expected.

§

UnexpectedEndOfStream

The text ends in the middle of markup.

§

InvalidCharacterReference(TextPos)

A character reference to a code point that is not a Unicode scalar value (a surrogate or a number above 0x10FFFF).

§

InvalidPiTarget(TextPos)

A processing instruction target that is xml in any case or contains :.

§

PiWithoutWhitespace(TextPos)

A processing instruction without whitespace between its target and its data.

§

InvalidXmlDeclaration(&'static str, TextPos)

An XML declaration with a pseudo-attribute that is not version, encoding or standalone as written, or with an invalid value (the reason).

§

InvalidQName(TextPos)

A name that starts with :, which is not a qualified name.

§

EmptyPrefixedNamespace(String, TextPos)

A prefix declared with an empty namespace name (the prefix).

§

XmlnsPrefixDeclared(TextPos)

A declaration of the xmlns prefix.

§

DuplicatedNamespaceDeclaration(String, TextPos)

The default namespace (xmlns) or the xml prefix (xmlns:xml) declared twice on an element (the attribute name).

§

PrefixedXmlnsAttribute(String, TextPos)

An attribute whose local name is xmlns and which has a prefix (its name).

§

DepthLimitReached

Elements nested deeper than crate::Limits::depth.

§

UnsupportedEncoding(String)

A document in an encoding that decode does not read: the name its XML declaration gives, or UCS-4 or EBCDIC for a document whose first bytes are in one of those.

§

EncodingMismatch

The first bytes of a document (a byte order mark, or <? in UTF-16) and its XML declaration name different encodings.

Fields

§found: &'static str

What the first bytes say.

§declared: String

The encoding the XML declaration names.

§

InvalidEncodedBytes

Bytes that are not a character in the encoding of the document.

Fields

§encoding: &'static str

The encoding.

§pos: TextPos

The position of the character they would be, in the decoded text.

Implementations§

Source§

impl Error

Source

pub fn pos(&self) -> TextPos

The position of the error; 1:1 for the errors that have none.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Error

Source§

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl Hash for Error

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Forget for Error

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.