use crate::core::delta::operation::{EmptyAttributes, Operation, OperationAttributes}; // pub type RichTextOpBuilder = OperationsBuilder; pub type PlainTextOpBuilder = OperationsBuilder; #[derive(Default)] pub struct OperationsBuilder { operations: Vec>, } impl OperationsBuilder where T: OperationAttributes, { pub fn new() -> OperationsBuilder { OperationsBuilder::default() } pub fn retain_with_attributes(mut self, n: usize, attributes: T) -> OperationsBuilder { let retain = Operation::retain_with_attributes(n, attributes); self.operations.push(retain); self } pub fn retain(mut self, n: usize) -> OperationsBuilder { let retain = Operation::retain(n); self.operations.push(retain); self } pub fn delete(mut self, n: usize) -> OperationsBuilder { self.operations.push(Operation::Delete(n)); self } pub fn insert_with_attributes(mut self, s: &str, attributes: T) -> OperationsBuilder { let insert = Operation::insert_with_attributes(s, attributes); self.operations.push(insert); self } pub fn insert(mut self, s: &str) -> OperationsBuilder { let insert = Operation::insert(s); self.operations.push(insert); self } pub fn build(self) -> Vec> { self.operations } }