BatchCommand

Struct BatchCommand 

Source
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: String

Description of the batch operation

Implementations§

Source§

impl BatchCommand

Source

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");
Source

pub fn add_command(self, command: Box<dyn EditorCommand>) -> Self

Add a command to the batch

Source

pub fn add_commands(self, commands: Vec<Box<dyn EditorCommand>>) -> Self

Add multiple commands to the batch

Trait Implementations§

Source§

impl Debug for BatchCommand

Source§

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

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

impl EditorCommand for BatchCommand

Source§

fn execute(&self, document: &mut EditorDocument) -> Result<CommandResult>

Execute the command on the given document Read more
Source§

fn description(&self) -> &str

Get a human-readable description of the command
Source§

fn memory_usage(&self) -> usize

Get the estimated memory usage of this command Read more
Source§

fn modifies_content(&self) -> bool

Check if this command modifies document content Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.