Skip to main content

StructuralOp

Enum StructuralOp 

Source
#[non_exhaustive]
pub enum StructuralOp { InsertField { parent: ParentRef, index: usize, name: String, value: String, }, RemoveField { parent: ParentRef, index: usize, }, RenameKey { parent: ParentRef, index: usize, new_name: String, }, ReorderChild { parent: ParentRef, from: usize, to: usize, }, SetValue { parent: ParentRef, index: usize, value: String, }, InsertElement { parent: ParentRef, index: usize, value: String, }, RemoveElement { parent: ParentRef, index: usize, }, SwapEnumVariant { variant: SyntaxNode, new_name: String, new_fields: Vec<String>, placeholder: String, }, AddFieldAcrossRows { list: SyntaxNode, name: String, value: String, }, }
Expand description

A single named structural-edit operation (the E008 transform vocabulary).

The set is derived from FR-003 (add / remove / reorder / rename fields and elements; change an enum variant) and FR-007 (add / remove rows = elements with sibling-inferred style). Each op identifies its target by an ast-navigable address (ParentRef + child index); see the module docs.

#[non_exhaustive] so the vocabulary can grow without a breaking change.

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

InsertField

Insert a field: value entry into a struct (or key: value into a map) at index (clamped to the entry count; appends past the end). For a map, name is the key’s literal RON text (e.g. "k" or 1); for a struct it is the bare field identifier.

Fields

§parent: ParentRef

The struct / map / enum-variant payload to insert into.

§index: usize

0-based insertion index among existing entries (clamped; append at end).

§name: String

The field name (struct: bare ident) or key literal (map: RON text).

§value: String

The new value’s literal RON text.

§

RemoveField

Remove the entry at index from a struct / map / enum-variant payload, taking only the entry and its own trivia and normalizing the separator (no dangling / doubled / orphaned comma) per FR-021.

Fields

§parent: ParentRef

The struct / map / enum-variant payload to remove from.

§index: usize

0-based index of the entry to remove.

§

RenameKey

Rename the struct-field name / map-key at index to new_name in place. Blocks with BlockedReason::RenameCollision if new_name already names another entry in the same parent (collision scope = the immediate enclosing struct/map), leaving the document byte-unchanged (FR-003).

Fields

§parent: ParentRef

The struct / map / enum-variant payload whose entry is renamed.

§index: usize

0-based index of the entry to rename.

§new_name: String

The replacement field name / key literal.

§

ReorderChild

Move the child at from to be at position to within parent, composed as one transform (remove + re-insert) producing one new CST. Works for a struct/map entry or a list/tuple element.

Fields

§parent: ParentRef

The collection whose child is moved.

§from: usize

0-based source index of the child to move.

§to: usize

0-based destination index (in the pre-move indexing).

§

SetValue

Replace the value at index within parent with value (new literal RON text). For a struct/map entry this replaces the entry’s value (the part after :); for a list/tuple it replaces the element.

Fields

§parent: ParentRef

The collection whose child value is replaced.

§index: usize

0-based index of the entry/element whose value is set.

§value: String

The replacement value’s literal RON text.

§

InsertElement

Insert an element into a list / tuple at index (clamped; append past the end), adopting the collection’s existing layout style — indentation and trailing-comma convention inferred from its siblings, or the document’s default for an empty collection (AD-005, FR-007).

Fields

§parent: ParentRef

The list / tuple to insert into.

§index: usize

0-based insertion index among existing elements (clamped; append).

§value: String

The new element’s literal RON text.

§

RemoveElement

Remove the element at index from a list / tuple, taking only the element and its own trivia and normalizing the separator (FR-021).

Fields

§parent: ParentRef

The list / tuple to remove from.

§index: usize

0-based index of the element to remove.

§

SwapEnumVariant

Swap an enum variant’s name + field set in place: rename the variant to new_name, keep a field present in both old and new (its value/bytes preserved), remove a field present only in the old variant, and add a field present only in the new variant with placeholder as its value (FR-003).

Fields

§variant: SyntaxNode

The enum-variant node to swap.

§new_name: String

The new variant name.

§new_fields: Vec<String>

The new variant’s field set, in order (struct-like variants); empty for a bare variant.

§placeholder: String

The placeholder value text used for a field present only in the new variant.

§

AddFieldAcrossRows

Add the field name: value to every record (struct element) of a list, batched into one transform (the multi-node op of ADR-0007 / data-model). Records that are not structs are skipped. The field is appended to each record.

Fields

§list: SyntaxNode

The list whose struct elements each gain the field.

§name: String

The new field name (bare ident).

§value: String

The new field’s value text.

Trait Implementations§

Source§

impl Clone for StructuralOp

Source§

fn clone(&self) -> StructuralOp

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 StructuralOp

Source§

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

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

impl Eq for StructuralOp

Source§

impl PartialEq for StructuralOp

Source§

fn eq(&self, other: &StructuralOp) -> 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 StructuralOp

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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, 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.