# loroscope Typed structs for [Loro](https://loro.dev/) CRDTs. [Loro](https://loro.dev/) is a CRDT library — it gives you conflict-free replicated containers (lists, maps, trees, rich text, etc.) with undo/redo, sync, and time travel. But working with it directly means string-keyed container lookups and manual `LoroValue` matching. `#[loroscope]` generates typed accessors from a struct definition, so field access is checked at compile time. ## Example ```rust use loroscope::loroscope; #[loroscope] struct TodoItem { title: Text, done: bool, } #[loroscope] struct App { todos: List, } let app = App::new(); let item = app.todos().push_new(); item.title().insert(0, "Buy milk").unwrap(); item.set_done(false); assert_eq!(app.todos().len(), 1); assert!(!app.todos().get(0).unwrap().done()); // The underlying LoroDoc is always available for export, import, // undo, subscriptions, etc. let _doc = app.doc(); ``` ## Field types | Type | Accessor | |---|---| | `f64`, `i64`, `bool`, `String` | Getter + `set_` setter | | [`Text`], [`Counter`] | Getter returning the container | | [`List`], [`Map`], [`MovableList`], [`Tree`] | Getter returning a typed collection | | `LoroList`, `LoroMap`, `LoroText`, ... | Getter returning the raw Loro container | | Any `#[loroscope]` struct | Getter returning a nested typed view | [`Text`]: https://docs.rs/loroscope/latest/loroscope/type.Text.html [`Counter`]: https://docs.rs/loroscope/latest/loroscope/type.Counter.html [`List`]: https://docs.rs/loroscope/latest/loroscope/struct.List.html [`Map`]: https://docs.rs/loroscope/latest/loroscope/struct.Map.html [`MovableList`]: https://docs.rs/loroscope/latest/loroscope/struct.MovableList.html [`Tree`]: https://docs.rs/loroscope/latest/loroscope/struct.Tree.html