serialize.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. use crate::prelude::ScopeIdx;
  2. use serde::{Deserialize, Serialize};
  3. /// A `DomEdit` represents a serialzied form of the VirtualDom's trait-based API. This allows streaming edits across the
  4. /// network or through FFI boundaries.
  5. #[derive(Debug, Serialize, Deserialize)]
  6. #[serde(tag = "type")]
  7. pub enum DomEdits<'bump> {
  8. PushRoot {
  9. root: u64,
  10. },
  11. AppendChild,
  12. ReplaceWith,
  13. Remove,
  14. RemoveAllChildren,
  15. CreateTextNode {
  16. text: &'bump str,
  17. id: u64,
  18. },
  19. CreateElement {
  20. tag: &'bump str,
  21. id: u64,
  22. },
  23. CreateElementNs {
  24. tag: &'bump str,
  25. id: u64,
  26. ns: &'bump str,
  27. },
  28. CreatePlaceholder {
  29. id: u64,
  30. },
  31. NewEventListener {
  32. event: &'bump str,
  33. scope: ScopeIdx,
  34. node: u64,
  35. idx: usize,
  36. },
  37. RemoveEventListener {
  38. event: &'bump str,
  39. },
  40. SetText {
  41. text: &'bump str,
  42. },
  43. SetAttribute {
  44. field: &'bump str,
  45. value: &'bump str,
  46. ns: Option<&'bump str>,
  47. },
  48. RemoveAttribute {
  49. name: &'bump str,
  50. },
  51. }