pub struct BatchCommand {
pub commands: Vec<Box<dyn EditorCommand>>,
pub description: String,
}Expand description
Batch command that executes multiple commands as a single atomic operation
Fields§
§commands: Vec<Box<dyn EditorCommand>>Commands to execute in order
description: StringDescription of the batch operation
Implementations§
Source§impl BatchCommand
impl BatchCommand
Sourcepub fn new(description: String) -> Self
pub fn new(description: String) -> Self
Create a new batch command
§Examples
use ass_editor::{BatchCommand, InsertTextCommand, DeleteTextCommand, Position, Range, EditorDocument, EditorCommand};
let mut doc = EditorDocument::from_content("Hello World").unwrap();
let batch = BatchCommand::new("Multiple operations".to_string())
.add_command(Box::new(InsertTextCommand::new(Position::new(5), " beautiful".to_string())))
.add_command(Box::new(DeleteTextCommand::new(Range::new(Position::new(15), Position::new(21)))));
let result = batch.execute(&mut doc).unwrap();
assert!(result.success);
assert_eq!(doc.text(), "Hello beautiful");Sourcepub fn add_command(self, command: Box<dyn EditorCommand>) -> Self
pub fn add_command(self, command: Box<dyn EditorCommand>) -> Self
Add a command to the batch
Sourcepub fn add_commands(self, commands: Vec<Box<dyn EditorCommand>>) -> Self
pub fn add_commands(self, commands: Vec<Box<dyn EditorCommand>>) -> Self
Add multiple commands to the batch
Trait Implementations§
Source§impl Debug for BatchCommand
impl Debug for BatchCommand
Source§impl EditorCommand for BatchCommand
impl EditorCommand for BatchCommand
Source§fn execute(&self, document: &mut EditorDocument) -> Result<CommandResult>
fn execute(&self, document: &mut EditorDocument) -> Result<CommandResult>
Execute the command on the given document Read more
Source§fn description(&self) -> &str
fn description(&self) -> &str
Get a human-readable description of the command
Source§fn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Get the estimated memory usage of this command Read more
Source§fn modifies_content(&self) -> bool
fn modifies_content(&self) -> bool
Check if this command modifies document content Read more
Auto Trait Implementations§
impl Freeze for BatchCommand
impl !RefUnwindSafe for BatchCommand
impl Send for BatchCommand
impl Sync for BatchCommand
impl Unpin for BatchCommand
impl !UnwindSafe for BatchCommand
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
Mutably borrows from an owned value. Read more