pub struct Edit {
pub file: PathBuf,
pub byte_start: usize,
pub byte_end: usize,
pub new_text: String,
pub expected_before: EditVerification,
}Expand description
The fundamental edit primitive: byte-span replacement with verification.
All high-level operations (AST transforms, structural edits, diffs) compile down to this single primitive. Intelligence lives in span acquisition, not application.
Fields§
§file: PathBufPath to the file to edit (absolute, workspace-relative resolved)
byte_start: usizeStarting byte offset (inclusive)
byte_end: usizeEnding byte offset (exclusive)
new_text: StringNew text to insert at [byte_start, byte_end)
expected_before: EditVerificationVerification of what we expect to find before applying
Implementations§
Source§impl Edit
impl Edit
Sourcepub fn new(
file: impl Into<PathBuf>,
byte_start: usize,
byte_end: usize,
new_text: impl Into<String>,
expected_before: impl Into<String>,
) -> Self
pub fn new( file: impl Into<PathBuf>, byte_start: usize, byte_end: usize, new_text: impl Into<String>, expected_before: impl Into<String>, ) -> Self
Create a new edit with automatic verification generation.
Sourcepub fn with_verification(
file: impl Into<PathBuf>,
byte_start: usize,
byte_end: usize,
new_text: impl Into<String>,
verification: EditVerification,
) -> Self
pub fn with_verification( file: impl Into<PathBuf>, byte_start: usize, byte_end: usize, new_text: impl Into<String>, verification: EditVerification, ) -> Self
Create an edit with explicit verification strategy.
Sourcepub fn apply(&self) -> Result<EditResult, EditError>
pub fn apply(&self) -> Result<EditResult, EditError>
Apply this edit to the file system atomically.
Uses tempfile + fsync + rename for crash safety.
Sourcepub fn apply_batch(edits: Vec<Edit>) -> Result<Vec<EditResult>, EditError>
pub fn apply_batch(edits: Vec<Edit>) -> Result<Vec<EditResult>, EditError>
Apply multiple edits to the same file in a single atomic operation.
Edits are sorted by byte_start descending and applied bottom-to-top to avoid offset invalidation.
Trait Implementations§
impl Eq for Edit
impl StructuralPartialEq for Edit
Auto Trait Implementations§
impl Freeze for Edit
impl RefUnwindSafe for Edit
impl Send for Edit
impl Sync for Edit
impl Unpin for Edit
impl UnsafeUnpin for Edit
impl UnwindSafe for Edit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.