diff options
| author | Josh Kingsley <josh@joshkingsley.me> | 2025-11-23 17:27:44 +0200 |
|---|---|---|
| committer | Josh Kingsley <josh@joshkingsley.me> | 2025-11-23 17:27:44 +0200 |
| commit | c2a6efb1b761014a90d90373cad47a14054af40b (patch) | |
| tree | 0c1127b0fea0456409502ec9a3105fe18a8a6434 /crdt/src/doc.rs | |
| parent | eb96b8eba0faf07adc5be4463759ec8b64ddc0e0 (diff) | |
feat(crdt): add wasm-bindgen
Diffstat (limited to 'crdt/src/doc.rs')
| -rw-r--r-- | crdt/src/doc.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crdt/src/doc.rs b/crdt/src/doc.rs index bbd24d0..fcca1d8 100644 --- a/crdt/src/doc.rs +++ b/crdt/src/doc.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use thiserror::Error; use uuid::Uuid; @@ -41,21 +42,33 @@ impl DerivableId for DerivedId { } } -#[derive(Default)] +impl Serialize for DerivedId { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +#[derive(Default, Serialize)] pub struct Doc { pub(crate) grids: Vec<Grid>, } +#[derive(Serialize)] pub struct Grid { pub(crate) id: DerivedId, pub(crate) rows: Vec<Row>, } +#[derive(Serialize)] pub struct Row { pub(crate) id: DerivedId, pub(crate) cells: Vec<Cell>, } +#[derive(Serialize)] pub struct Cell { pub(crate) id: DerivedId, } |
