Skip to main content

CopyError

Enum CopyError 

Source
pub enum CopyError {
    AttributeAfterContent {
        name: String,
    },
    AttributeOutsideElement {
        name: String,
    },
    SchemaMismatch,
    Unsupported(&'static str),
    Document(BufferDocumentError),
    Atomize(XPathError),
}
Expand description

Why a node could not be copied.

use bumpalo::Bump;
use xsd_schema::document::{BufferDocument, BufferDocumentBuilder};
use xsd_schema::document::{BufferDocumentOptions, CopyError, CopyOptions};
use xsd_schema::namespace::NameTable;
use xsd_schema::navigator::DomNavigator;

let arena = Bump::new();
let names = NameTable::new();
let source = BufferDocument::from_reader_default(r#"<a k="v"/>"#.as_bytes(), &arena, &names)?;
let mut attr = source.create_navigator();
attr.move_to_first_child();
attr.move_to_first_attribute();

// Nothing is open, so there is no element to put the attribute on.
let mut builder =
    BufferDocumentBuilder::new(&arena, &names, None, BufferDocumentOptions::default())?;
match builder.copy_attribute(&attr, CopyOptions::default()) {
    Err(CopyError::AttributeOutsideElement { name }) => assert_eq!(name, "k"),
    other => panic!("expected a refusal, got {other:?}"),
}

Variants§

§

AttributeAfterContent

An attribute was appended to an element that already has a child (XQuery XQTY0024).

Fields

§name: String

The attribute’s qualified name, as the source spells it.

§

AttributeOutsideElement

An attribute was appended with no element open, i.e. at document level (XQuery XQTY0024).

Fields

§name: String

The attribute’s qualified name, as the source spells it.

§

SchemaMismatch

Annotations::Preserve was asked for, but the source document is bound to a different SchemaSet than the document being built, so its type keys mean nothing here.

§

Unsupported(&'static str)

A node kind this copy cannot represent: a namespace node used as content, or a node that is not an attribute passed to copy_attribute.

§

Document(BufferDocumentError)

The builder refused the node (the document is full, or an element was closed that was never opened).

§

Atomize(XPathError)

An atomic item could not be atomized to a string value.

Trait Implementations§

Source§

impl Debug for CopyError

Source§

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

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

impl Display for CopyError

Source§

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

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

impl Error for CopyError

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

Replaced by Error::source.
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 From<BufferDocumentError> for CopyError

Source§

fn from(source: BufferDocumentError) -> Self

Converts to this type from the input type.
Source§

impl From<CopyError> for ComposeError

Source§

fn from(source: CopyError) -> Self

Wraps a copy error with no form path; the emitter attaches it.

Source§

impl From<XPathError> for CopyError

Source§

fn from(source: XPathError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for CopyError

§

impl !UnwindSafe for CopyError

§

impl Forget for CopyError

§

impl Freeze for CopyError
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, &'static str: Freeze, *const () is !null: Freeze, PhantomData<ErrorData<CustomOwner>>: Freeze, *const str is !null: Freeze, PhantomData<str>: Freeze, *const ArcInner<RaisedErrorData> is !null: Freeze, PhantomData<ArcInner<RaisedErrorData>>: Freeze,

§

impl Move for CopyError

§

impl Send for CopyError
where RawVecInner: Send, &'static str: Send, Repr: Send, BoxRaw<str>: Send, Arc<RaisedErrorData>: Send,

§

impl Sync for CopyError
where RawVecInner: Sync, Repr: Sync, BoxRaw<str>: Sync, Arc<RaisedErrorData>: Sync,

§

impl Unpin for CopyError
where *const u8 is !null: Unpin, &'static str: Unpin, *const () is !null: Unpin, &'static SimpleMessage: Unpin, *const Custom is !null: Unpin, Box<str>: Unpin, Arc<RaisedErrorData>: Unpin,

§

impl UnsafeUnpin for CopyError
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, &'static str: UnsafeUnpin, *const () is !null: UnsafeUnpin, PhantomData<ErrorData<CustomOwner>>: UnsafeUnpin, *const str is !null: UnsafeUnpin, PhantomData<str>: UnsafeUnpin, *const ArcInner<RaisedErrorData> is !null: UnsafeUnpin, PhantomData<ArcInner<RaisedErrorData>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.