#[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
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
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
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
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
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
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
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
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: SyntaxNodeThe enum-variant node to swap.
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.
Trait Implementations§
Source§impl Clone for StructuralOp
impl Clone for StructuralOp
Source§fn clone(&self) -> StructuralOp
fn clone(&self) -> StructuralOp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more