automerge/rust/edit-trace
alexjg 08801ab580
automerge-rs: Introduce ReadDoc and SyncDoc traits and add documentation (#511)
The Rust API has so far grown somewhat organically driven by the needs of the
javascript implementation. This has led to an API which is quite awkward and
unfamiliar to Rust programmers. Additionally there is no documentation to speak
of. This commit is the first movement towards cleaning things up a bit. We touch
a lot of files but the changes are all very mechanical. We introduce a few
traits to abstract over the common operations between `Automerge` and
`AutoCommit`, and add a whole bunch of documentation.

* Add a `ReadDoc` trait to describe methods which read value from a document.
  make `Transactable` extend `ReadDoc`
* Add a `SyncDoc` trait to describe methods necessary for synchronizing
  documents.
* Put the `SyncDoc` implementation for `AutoCommit` behind `AutoCommit::sync` to
  ensure that any open transactions are closed before taking part in the sync
  protocol
* Split `OpObserver` into two traits: `OpObserver` + `BranchableObserver`.
  `BranchableObserver` captures the methods which are only needed for observing
  transactions.
* Add a whole bunch of documentation.

The main changes Rust users will need to make is:

* Import the `ReadDoc` trait wherever you are using the methods which have been
  moved to it. Optionally change concrete paramters on functions to `ReadDoc`
  constraints.
* Likewise import the `SyncDoc` trait wherever you are doing synchronisation
  work
* If you are using the `AutoCommit::*_sync_message` methods you will need to add
  a call to `AutoCommit::sync()` first. E.g. `doc.generate_sync_message` becomes
  `doc.sync().generate_sync_message`
* If you have an implementation of `OpObserver` which you are using in an
  `AutoCommit` then split it into an implementation of `OpObserver` and
  `BranchableObserver`
2023-01-30 19:37:03 +00:00
..
benches Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
src automerge-rs: Introduce ReadDoc and SyncDoc traits and add documentation (#511) 2023-01-30 19:37:03 +00:00
.gitignore Text v2. JS Api now uses text by default (#462) 2022-12-09 23:48:07 +00:00
automerge-1.0.js Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
automerge-js.js rewrite opnode to store usize instead of Op (#471) 2022-12-10 10:36:05 +00:00
automerge-wasm.js rewrite opnode to store usize instead of Op (#471) 2022-12-10 10:36:05 +00:00
baseline.js Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
Cargo.toml automerge-cli: remove a bunch of bad dependencies (#478) 2022-12-14 18:06:19 +00:00
editing-trace.js Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
edits.json Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
Makefile Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00
package.json rewrite opnode to store usize instead of Op (#471) 2022-12-10 10:36:05 +00:00
README.md Move rust workspace into ./rust 2022-10-16 19:55:51 +01:00

Edit trace benchmarks

Try the different editing traces on different automerge implementations

Automerge Experiement - pure rust

make rust

Benchmarks

There are some criterion benchmarks in the benches folder which can be run with cargo bench or cargo criterion. For flamegraphing, cargo flamegraph --bench main -- --bench "save" # or "load" or "replay" or nothing can be useful.

Automerge Experiement - wasm api

make wasm

Automerge Experiment - JS wrapper

make js

Automerge 1.0 pure javascript - new fast backend

This assumes automerge has been checked out in a directory along side this repo

node automerge-1.0.js

Automerge 1.0 with rust backend

This assumes automerge has been checked out in a directory along side this repo

node automerge-rs.js

Baseline Test. Javascript Array with no CRDT info

make baseline