automerge / automerge-swift

Swift language bindings presenting Automerge

Home Page:https://automerge.org/automerge-swift/documentation/automerge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update to Automerge 0.4.0

heckj opened this issue · comments

I saw that Automerge-rs released an updated 0.4.0 crate, and went and took a quick stab at updating this repo to use it.

Unfortunately, with the version update there's a few breaking changes to the internal pieces that enable the UniFFI overlay. When I updated to 0.4.0, I received the following errors when invoking cargo build:

error[E0050]: method `insert` has 5 parameters but the declaration in trait `automerge::OpObserver::insert` has 6
  --> src/patches/observer.rs:90:9
   |
90 | /         &mut self,
91 | |         doc: &R,
92 | |         obj: am::ObjId,
93 | |         index: usize,
94 | |         tagged_value: (am::Value<'_>, am::ObjId),
   | |________________________________________________^ expected 6 parameters, found 5
   |
   = note: `insert` from trait: `fn(&mut Self, &R, automerge::ObjId, usize, (automerge::Value<'_>, automerge::ObjId), bool)`

error[E0046]: not all trait items implemented, missing: `mark`, `unmark`
  --> src/patches/observer.rs:88:1
   |
88 | impl am::OpObserver for Observer {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `mark`, `unmark` in implementation
   |
   = help: implement the missing item: `fn mark<R, M>(&mut self, _: &'a R, _: automerge::ObjId, _: M) where R: ReadDoc, M: Iterator, std::iter::Iterator::Item = automerge::marks::Mark<'a> { todo!() }`
   = help: implement the missing item: `fn unmark<R>(&mut self, _: &R, _: automerge::ObjId, _: &str, _: usize, _: usize) where R: ReadDoc { todo!() }`

Since I'm only minimally proficient at Rust, I thought I'd wait until @alexjg was available to help make this migration, as I'm uncertain of the implications as well as implementation changes needed.

I went poking at the error in the Rust code, and there's a new Boolean value on automerge::OpObserver::insert in 0.4.x:

pub trait OpObserver {
    /// A new value has been inserted into the given object.
    ///
    /// - `doc`: a handle to the doc after the op has been inserted, can be used to query information
    /// - `objid`: the object that has been inserted into.
    /// - `index`: the index the new value has been inserted at.
    /// - `tagged_value`: the value that has been inserted and the id of the operation that did the
    /// insert.
    fn insert<R: ReadDoc>(
        &mut self,
        doc: &R,
        objid: ExId,
        index: usize,
        tagged_value: (Value<'_>, ExId),
        conflict: bool,
    );

The Boolean that was added on other pieces references: /// - conflict: whether this put conflicts with other operations.

I'm not clear on the behavior for 0.3.x - if it defaulted to true or false.