serialize.rs 1.2 KB

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