extension.rs 628 B

1234567891011121314151617181920
  1. use crate::core::{Attribute, Delta, Interval};
  2. pub type InsertExtension = Box<dyn InsertExt>;
  3. pub type FormatExtension = Box<dyn FormatExt>;
  4. pub type DeleteExtension = Box<dyn DeleteExt>;
  5. pub trait InsertExt {
  6. fn ext_name(&self) -> &str;
  7. fn apply(&self, delta: &Delta, replace_len: usize, text: &str, index: usize) -> Option<Delta>;
  8. }
  9. pub trait FormatExt {
  10. fn ext_name(&self) -> &str;
  11. fn apply(&self, delta: &Delta, interval: Interval, attribute: &Attribute) -> Option<Delta>;
  12. }
  13. pub trait DeleteExt {
  14. fn ext_name(&self) -> &str;
  15. fn apply(&self, delta: &Delta, interval: Interval) -> Option<Delta>;
  16. }