mod.rs 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. pub use delete::*;
  2. pub use format::*;
  3. pub use insert::*;
  4. use lib_ot::core::AttributeEntry;
  5. use lib_ot::{core::Interval, text_delta::DeltaTextOperations};
  6. mod delete;
  7. mod format;
  8. mod helper;
  9. mod insert;
  10. pub type InsertExtension = Box<dyn InsertExt + Send + Sync>;
  11. pub type FormatExtension = Box<dyn FormatExt + Send + Sync>;
  12. pub type DeleteExtension = Box<dyn DeleteExt + Send + Sync>;
  13. pub trait InsertExt {
  14. fn ext_name(&self) -> &str;
  15. fn apply(
  16. &self,
  17. delta: &DeltaTextOperations,
  18. replace_len: usize,
  19. text: &str,
  20. index: usize,
  21. ) -> Option<DeltaTextOperations>;
  22. }
  23. pub trait FormatExt {
  24. fn ext_name(&self) -> &str;
  25. fn apply(
  26. &self,
  27. delta: &DeltaTextOperations,
  28. interval: Interval,
  29. attribute: &AttributeEntry,
  30. ) -> Option<DeltaTextOperations>;
  31. }
  32. pub trait DeleteExt {
  33. fn ext_name(&self) -> &str;
  34. fn apply(&self, delta: &DeltaTextOperations, interval: Interval) -> Option<DeltaTextOperations>;
  35. }