Skip to content

Commit

Permalink
0.5.10 core library update (#155)
Browse files Browse the repository at this point in the history
* advance to core library version 0.5.10 - update PatchAction API to reflect marks changes

* corresponding API updates for removing Marks from Patch:Insert

* rustfmt cleanup
  • Loading branch information
heckj authored May 1, 2024
1 parent 11250a1 commit 7880d65
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 54 deletions.
31 changes: 15 additions & 16 deletions AutomergeUniffi/automerge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,12 @@ open class Doc:
}

public convenience init() {
let pointer = try! rustCall {
uniffi_uniffi_automerge_fn_constructor_doc_new(
$0
)
}
let pointer =
try! rustCall {
uniffi_uniffi_automerge_fn_constructor_doc_new(
$0
)
}
self.init(unsafeFromRawPointer: pointer)
}

Expand Down Expand Up @@ -1385,11 +1386,12 @@ open class SyncState:
}

public convenience init() {
let pointer = try! rustCall {
uniffi_uniffi_automerge_fn_constructor_syncstate_new(
$0
)
}
let pointer =
try! rustCall {
uniffi_uniffi_automerge_fn_constructor_syncstate_new(
$0
)
}
self.init(unsafeFromRawPointer: pointer)
}

Expand Down Expand Up @@ -1998,8 +2000,7 @@ public enum PatchAction {
case insert(
obj: ObjId,
index: UInt64,
values: [Value],
marks: [String: Value]
values: [Value]
)
case spliceText(
obj: ObjId,
Expand Down Expand Up @@ -2046,8 +2047,7 @@ public struct FfiConverterTypePatchAction: FfiConverterRustBuffer {
case 2: return try .insert(
obj: FfiConverterTypeObjId.read(from: &buf),
index: FfiConverterUInt64.read(from: &buf),
values: FfiConverterSequenceTypeValue.read(from: &buf),
marks: FfiConverterDictionaryStringTypeValue.read(from: &buf)
values: FfiConverterSequenceTypeValue.read(from: &buf)
)

case 3: return try .spliceText(
Expand Down Expand Up @@ -2096,12 +2096,11 @@ public struct FfiConverterTypePatchAction: FfiConverterRustBuffer {
FfiConverterTypeProp.write(prop, into: &buf)
FfiConverterTypeValue.write(value, into: &buf)

case let .insert(obj, index, values, marks):
case let .insert(obj, index, values):
writeInt(&buf, Int32(2))
FfiConverterTypeObjId.write(obj, into: &buf)
FfiConverterUInt64.write(index, into: &buf)
FfiConverterSequenceTypeValue.write(values, into: &buf)
FfiConverterDictionaryStringTypeValue.write(marks, into: &buf)

case let .spliceText(obj, index, value, marks):
writeInt(&buf, Int32(3))
Expand Down
11 changes: 4 additions & 7 deletions Sources/Automerge/Patch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ public enum PatchAction: Equatable {
///
/// The property included within the `Put` can be either an index to a sequence, or a key into a map.
case Put(ObjId, Prop, Value)
/// Insert a collection of values at the index you provide for the identified object with the given marks
///
/// `marks` will only be set for text objects.
case Insert(obj: ObjId, index: UInt64, values: [Value], marks: [String: Value])
/// Insert a collection of values at the index you provide for the identified object.
case Insert(obj: ObjId, index: UInt64, values: [Value])
/// Splices characters into and/or removes characters from the identified object at a given position within it.
///
/// > Note: The unsigned 64bit integer is the index to a UTF-8 code point, and not a grapheme cluster index.
Expand All @@ -77,12 +75,11 @@ public enum PatchAction: Equatable {
switch ffi {
case let .put(obj, prop, value):
return .Put(ObjId(bytes: obj), Prop.fromFfi(prop), Value.fromFfi(value: value))
case let .insert(obj, index, values, marks):
case let .insert(obj, index, values):
return .Insert(
obj: ObjId(bytes: obj),
index: index,
values: values.map { Value.fromFfi(value: $0) },
marks: marks.mapValues(Value.fromFfi)
values: values.map { Value.fromFfi(value: $0) }
)
case let .spliceText(obj, index, value, marks):
return .SpliceText(
Expand Down
40 changes: 20 additions & 20 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ path = "uniffi-bindgen.rs"
required-features = ["uniffi/cli"]

[dependencies]
automerge = "0.5.9"
automerge = "0.5.10"
thiserror = "1.0.38"
uniffi = "0.27.0"
uniffi = "0.27.1"

[build-dependencies]
uniffi = {version = "0.27.0", features = ["build"] }
uniffi = {version = "0.27.1", features = ["build"] }

2 changes: 1 addition & 1 deletion rust/src/automerge.udl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ dictionary Patch {
[Enum]
interface PatchAction {
Put( ObjId obj, Prop prop, Value value);
Insert( ObjId obj, u64 index, sequence<Value> values, record<string, Value> marks);
Insert( ObjId obj, u64 index, sequence<Value> values);
SpliceText( ObjId obj, u64 index, string value, record<string, Value> marks);
Increment( ObjId obj, Prop prop, i64 value);
Conflict( ObjId obj, Prop prop);
Expand Down
8 changes: 1 addition & 7 deletions rust/src/patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub enum PatchAction {
obj: ObjId,
index: u64,
values: Vec<Value>,
marks: HashMap<String, Value>,
},
SpliceText {
obj: ObjId,
Expand Down Expand Up @@ -81,18 +80,13 @@ impl PatchAction {
},
value: value.into(),
},
am::PatchAction::Insert {
index,
values,
marks,
} => PatchAction::Insert {
am::PatchAction::Insert { index, values } => PatchAction::Insert {
obj: obj.into(),
index: index as u64,
values: values
.into_iter()
.map(|(v, id, _conflict)| Value::from((v.clone(), id.clone())))
.collect(),
marks: convert_marks(marks),
},
am::PatchAction::SpliceText {
index,
Expand Down

0 comments on commit 7880d65

Please sign in to comment.