Skip to main content

TreeEditError

Enum TreeEditError 

Source
#[non_exhaustive]
pub enum TreeEditError {
Show 16 variants Stale(StaleNode), NotANode { kind: SyntaxKind, }, NotAToken { kind: SyntaxKind, }, NoParent, NotSiblings, Position { position: usize, len: usize, }, ReadOnly { kind: SyntaxKind, }, Misplaced { kind: SyntaxKind, parent: SyntaxKind, }, TagContext, InvalidToken { kind: SyntaxKind, }, Syntax { code: Code, }, EmptyFragment, NotWellFormed, Limit { code: Code, }, Capacity, Internal,
}
Expand description

Why an edit of a SyntaxTree was refused. The tree is unchanged when an edit fails.

A distinct name from oneyaml’s own EditError: the oneyaml crate maps this type and never re-exports it.

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.
§

Stale(StaleNode)

A handle names no live element of this tree.

§

NotANode

Children were to be added under a token.

Fields

§kind: SyntaxKind

The token’s kind.

§

NotAToken

A token operation was given a node.

Fields

§kind: SyntaxKind

The node’s kind.

§

NoParent

The element has no parent (the stream root cannot be removed, replaced, or given siblings).

§

NotSiblings

The two ends of a range are not siblings, or the last comes before the first.

§

Position

A child position past the end.

Fields

§position: usize

The position asked for.

§len: usize

Number of children (or roots).

§

ReadOnly

The element cannot be changed this way: the inside of a scalar, alias, or error node; directives (they change the meaning of the whole document); tag properties and block scalar headers (their meaning is carried by the node: replace the node instead); tokens whose text cannot be replaced in place. kind: Error also for an edit that could change how recovered input reads (see Recovered input in the module docs).

Fields

§kind: SyntaxKind

The kind refused.

§

Misplaced

A fragment element may not sit under that parent (a stream anywhere, a document outside the stream, a YAML node directly in the stream).

Fields

§kind: SyntaxKind

The fragment element’s kind.

§parent: SyntaxKind

The parent’s kind.

§

TagContext

The fragment has tags resolved under other %TAG directives than the document it would go into.

§

InvalidToken

Replacement text does not read as exactly one token of the kind it replaces.

Fields

§kind: SyntaxKind

The token kind expected.

§

Syntax

Fragment text does not parse cleanly: the first error’s code.

Fields

§code: Code

Code of the first error.

§

EmptyFragment

An empty fragment cannot be inserted.

§

NotWellFormed

The edit is not well-formed: the text around it, read again through the parser, would not give the tree the edit produces (it has errors, or another structure). See the Well-formed edits section of the module docs for the exact rule.

§

Limit

The edit would exceed one of the tree’s Limits (limits apply to edits): the code of the limit diagnostic the edited text would re-parse with (Y2000 max_depth, counted from the tree’s root; Y2001 max_scalar_len; Y2002 max_document_size; Y2003 max_documents).

Fields

§code: Code

The limit diagnostic’s code.

§

Capacity

The slot space (2³² elements over the tree’s lifetime) or a fragment’s 4 GiB is exhausted.

§

Internal

An internal invariant failed (a bug; Y9000).

Trait Implementations§

Source§

impl Clone for TreeEditError

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 Copy for TreeEditError

Source§

impl Debug for TreeEditError

Source§

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

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

impl Display for TreeEditError

Source§

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

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

impl Eq for TreeEditError

Source§

impl Error for TreeEditError

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 From<StaleNode> for TreeEditError

Source§

fn from(s: StaleNode) -> Self

Converts to this type from the input type.
Source§

impl Hash for TreeEditError

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 TreeEditError

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 TreeEditError

Auto Trait Implementations§

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.