mutations.rs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. use crate::arena::ElementId;
  2. pub struct Renderer<'a> {
  3. mutations: Vec<Mutation<'a>>,
  4. }
  5. #[derive(Debug)]
  6. pub enum Mutation<'a> {
  7. SetAttribute {
  8. name: &'static str,
  9. value: &'a str,
  10. id: ElementId,
  11. },
  12. LoadTemplate {
  13. name: &'static str,
  14. index: usize,
  15. },
  16. SaveTemplate {
  17. name: &'static str,
  18. m: usize,
  19. },
  20. HydrateText {
  21. path: &'static [u8],
  22. value: &'a str,
  23. id: ElementId,
  24. },
  25. SetText {
  26. value: &'a str,
  27. id: ElementId,
  28. },
  29. ReplacePlaceholder {
  30. m: usize,
  31. path: &'static [u8],
  32. },
  33. AssignId {
  34. path: &'static [u8],
  35. id: ElementId,
  36. },
  37. // Take the current element and replace it with the element with the given id.
  38. Replace {
  39. id: ElementId,
  40. },
  41. CreateElement {
  42. name: &'a str,
  43. namespace: Option<&'a str>,
  44. id: ElementId,
  45. },
  46. CreateText {
  47. value: &'a str,
  48. },
  49. CreatePlaceholder,
  50. AppendChildren {
  51. m: usize,
  52. },
  53. }