Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Automerge 0.4.0 #21

Closed
heckj opened this issue Apr 12, 2023 · 1 comment · Fixed by #39
Closed

Update to Automerge 0.4.0 #21

heckj opened this issue Apr 12, 2023 · 1 comment · Fixed by #39
Assignees

Comments

@heckj
Copy link
Collaborator

heckj commented Apr 12, 2023

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.

@heckj
Copy link
Collaborator Author

heckj commented May 21, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants