@@ -587,6 +587,8 @@ public protocol DocProtocol: AnyObject {
587587
588588 func marksAt( obj: ObjId , heads: [ ChangeHash ] ) throws -> [ Mark ]
589589
590+ func marksAtPosition( obj: ObjId , position: Position , heads: [ ChangeHash ] ) throws -> [ Mark ]
591+
590592 func merge( other: Doc ) throws
591593
592594 func mergeWithPatches( other: Doc ) throws -> [ Patch ]
@@ -1141,6 +1143,18 @@ open class Doc:
11411143 } )
11421144 }
11431145
1146+ open func marksAtPosition( obj: ObjId , position: Position , heads: [ ChangeHash ] ) throws -> [ Mark ] {
1147+ try FfiConverterSequenceTypeMark . lift ( rustCallWithError ( FfiConverterTypeDocError . lift) {
1148+ uniffi_uniffi_automerge_fn_method_doc_marks_at_position (
1149+ self . uniffiClonePointer ( ) ,
1150+ FfiConverterTypeObjId . lower ( obj) ,
1151+ FfiConverterTypePosition . lower ( position) ,
1152+ FfiConverterSequenceTypeChangeHash . lower ( heads) ,
1153+ $0
1154+ )
1155+ } )
1156+ }
1157+
11441158 open func merge( other: Doc ) throws { try rustCallWithError ( FfiConverterTypeDocError . lift) {
11451159 uniffi_uniffi_automerge_fn_method_doc_merge (
11461160 self . uniffiClonePointer ( ) ,
@@ -1668,49 +1682,6 @@ public func FfiConverterTypeKeyValue_lower(_ value: KeyValue) -> RustBuffer {
16681682 FfiConverterTypeKeyValue . lower ( value)
16691683}
16701684
1671- public struct MapValue {
1672- public var value : [ String : AmValue ]
1673-
1674- // Default memberwise initializers are never public by default, so we
1675- // declare one manually.
1676- public init ( value: [ String : AmValue ] ) {
1677- self . value = value
1678- }
1679- }
1680-
1681- extension MapValue : Equatable , Hashable {
1682- public static func == ( lhs: MapValue , rhs: MapValue ) -> Bool {
1683- if lhs. value != rhs. value {
1684- return false
1685- }
1686- return true
1687- }
1688-
1689- public func hash( into hasher: inout Hasher ) {
1690- hasher. combine ( value)
1691- }
1692- }
1693-
1694- public struct FfiConverterTypeMapValue : FfiConverterRustBuffer {
1695- public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> MapValue {
1696- try MapValue (
1697- value: FfiConverterDictionaryStringTypeAMValue . read ( from: & buf)
1698- )
1699- }
1700-
1701- public static func write( _ value: MapValue , into buf: inout [ UInt8 ] ) {
1702- FfiConverterDictionaryStringTypeAMValue . write ( value. value, into: & buf)
1703- }
1704- }
1705-
1706- public func FfiConverterTypeMapValue_lift( _ buf: RustBuffer ) throws -> MapValue {
1707- try FfiConverterTypeMapValue . lift ( buf)
1708- }
1709-
1710- public func FfiConverterTypeMapValue_lower( _ value: MapValue ) -> RustBuffer {
1711- FfiConverterTypeMapValue . lower ( value)
1712- }
1713-
17141685public struct Mark {
17151686 public var start : UInt64
17161687 public var end : UInt64
@@ -1880,132 +1851,6 @@ public func FfiConverterTypePathElement_lower(_ value: PathElement) -> RustBuffe
18801851 FfiConverterTypePathElement . lower ( value)
18811852}
18821853
1883- public struct TextValue {
1884- public var value : String
1885- public var marks : [ Mark ]
1886-
1887- // Default memberwise initializers are never public by default, so we
1888- // declare one manually.
1889- public init ( value: String , marks: [ Mark ] ) {
1890- self . value = value
1891- self . marks = marks
1892- }
1893- }
1894-
1895- extension TextValue : Equatable , Hashable {
1896- public static func == ( lhs: TextValue , rhs: TextValue ) -> Bool {
1897- if lhs. value != rhs. value {
1898- return false
1899- }
1900- if lhs. marks != rhs. marks {
1901- return false
1902- }
1903- return true
1904- }
1905-
1906- public func hash( into hasher: inout Hasher ) {
1907- hasher. combine ( value)
1908- hasher. combine ( marks)
1909- }
1910- }
1911-
1912- public struct FfiConverterTypeTextValue : FfiConverterRustBuffer {
1913- public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> TextValue {
1914- try TextValue (
1915- value: FfiConverterString . read ( from: & buf) ,
1916- marks: FfiConverterSequenceTypeMark . read ( from: & buf)
1917- )
1918- }
1919-
1920- public static func write( _ value: TextValue , into buf: inout [ UInt8 ] ) {
1921- FfiConverterString . write ( value. value, into: & buf)
1922- FfiConverterSequenceTypeMark . write ( value. marks, into: & buf)
1923- }
1924- }
1925-
1926- public func FfiConverterTypeTextValue_lift( _ buf: RustBuffer ) throws -> TextValue {
1927- try FfiConverterTypeTextValue . lift ( buf)
1928- }
1929-
1930- public func FfiConverterTypeTextValue_lower( _ value: TextValue ) -> RustBuffer {
1931- FfiConverterTypeTextValue . lower ( value)
1932- }
1933-
1934- // Note that we don't yet support `indirect` for enums.
1935- // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
1936-
1937- public enum AmValue {
1938- case scalar(
1939- value: ScalarValue
1940- )
1941- case list(
1942- value: [ AmValue ]
1943- )
1944- case map(
1945- value: MapValue
1946- )
1947- case text(
1948- value: TextValue
1949- )
1950- }
1951-
1952- public struct FfiConverterTypeAMValue : FfiConverterRustBuffer {
1953- typealias SwiftType = AmValue
1954-
1955- public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> AmValue {
1956- let variant : Int32 = try readInt ( & buf)
1957- switch variant {
1958- case 1 : return try . scalar(
1959- value: FfiConverterTypeScalarValue . read ( from: & buf)
1960- )
1961-
1962- case 2 : return try . list(
1963- value: FfiConverterSequenceTypeAMValue . read ( from: & buf)
1964- )
1965-
1966- case 3 : return try . map(
1967- value: FfiConverterTypeMapValue . read ( from: & buf)
1968- )
1969-
1970- case 4 : return try . text(
1971- value: FfiConverterTypeTextValue . read ( from: & buf)
1972- )
1973-
1974- default : throw UniffiInternalError . unexpectedEnumCase
1975- }
1976- }
1977-
1978- public static func write( _ value: AmValue , into buf: inout [ UInt8 ] ) {
1979- switch value {
1980- case let . scalar( value) :
1981- writeInt ( & buf, Int32 ( 1 ) )
1982- FfiConverterTypeScalarValue . write ( value, into: & buf)
1983-
1984- case let . list( value) :
1985- writeInt ( & buf, Int32 ( 2 ) )
1986- FfiConverterSequenceTypeAMValue . write ( value, into: & buf)
1987-
1988- case let . map( value) :
1989- writeInt ( & buf, Int32 ( 3 ) )
1990- FfiConverterTypeMapValue . write ( value, into: & buf)
1991-
1992- case let . text( value) :
1993- writeInt ( & buf, Int32 ( 4 ) )
1994- FfiConverterTypeTextValue . write ( value, into: & buf)
1995- }
1996- }
1997- }
1998-
1999- public func FfiConverterTypeAMValue_lift( _ buf: RustBuffer ) throws -> AmValue {
2000- try FfiConverterTypeAMValue . lift ( buf)
2001- }
2002-
2003- public func FfiConverterTypeAMValue_lower( _ value: AmValue ) -> RustBuffer {
2004- FfiConverterTypeAMValue . lower ( value)
2005- }
2006-
2007- extension AmValue : Equatable , Hashable { }
2008-
20091854public enum DecodeSyncStateError {
20101855 case Internal( message: String )
20111856}
@@ -2372,6 +2217,59 @@ extension PatchAction: Equatable, Hashable {}
23722217// Note that we don't yet support `indirect` for enums.
23732218// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
23742219
2220+ public enum Position {
2221+ case cursor(
2222+ position: Cursor
2223+ )
2224+ case index(
2225+ position: UInt64
2226+ )
2227+ }
2228+
2229+ public struct FfiConverterTypePosition : FfiConverterRustBuffer {
2230+ typealias SwiftType = Position
2231+
2232+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> Position {
2233+ let variant : Int32 = try readInt ( & buf)
2234+ switch variant {
2235+ case 1 : return try . cursor(
2236+ position: FfiConverterTypeCursor . read ( from: & buf)
2237+ )
2238+
2239+ case 2 : return try . index(
2240+ position: FfiConverterUInt64 . read ( from: & buf)
2241+ )
2242+
2243+ default : throw UniffiInternalError . unexpectedEnumCase
2244+ }
2245+ }
2246+
2247+ public static func write( _ value: Position , into buf: inout [ UInt8 ] ) {
2248+ switch value {
2249+ case let . cursor( position) :
2250+ writeInt ( & buf, Int32 ( 1 ) )
2251+ FfiConverterTypeCursor . write ( position, into: & buf)
2252+
2253+ case let . index( position) :
2254+ writeInt ( & buf, Int32 ( 2 ) )
2255+ FfiConverterUInt64 . write ( position, into: & buf)
2256+ }
2257+ }
2258+ }
2259+
2260+ public func FfiConverterTypePosition_lift( _ buf: RustBuffer ) throws -> Position {
2261+ try FfiConverterTypePosition . lift ( buf)
2262+ }
2263+
2264+ public func FfiConverterTypePosition_lower( _ value: Position ) -> RustBuffer {
2265+ FfiConverterTypePosition . lower ( value)
2266+ }
2267+
2268+ extension Position : Equatable , Hashable { }
2269+
2270+ // Note that we don't yet support `indirect` for enums.
2271+ // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
2272+
23752273public enum Prop {
23762274 case key(
23772275 value: String
@@ -2892,28 +2790,6 @@ private struct FfiConverterSequenceTypePathElement: FfiConverterRustBuffer {
28922790 }
28932791}
28942792
2895- private struct FfiConverterSequenceTypeAMValue : FfiConverterRustBuffer {
2896- typealias SwiftType = [ AmValue ]
2897-
2898- public static func write( _ value: [ AmValue ] , into buf: inout [ UInt8 ] ) {
2899- let len = Int32 ( value. count)
2900- writeInt ( & buf, len)
2901- for item in value {
2902- FfiConverterTypeAMValue . write ( item, into: & buf)
2903- }
2904- }
2905-
2906- public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> [ AmValue ] {
2907- let len : Int32 = try readInt ( & buf)
2908- var seq = [ AmValue] ( )
2909- seq. reserveCapacity ( Int ( len) )
2910- for _ in 0 ..< len {
2911- try seq. append ( FfiConverterTypeAMValue . read ( from: & buf) )
2912- }
2913- return seq
2914- }
2915- }
2916-
29172793private struct FfiConverterSequenceTypeScalarValue : FfiConverterRustBuffer {
29182794 typealias SwiftType = [ ScalarValue ]
29192795
@@ -2980,29 +2856,6 @@ private struct FfiConverterSequenceTypeChangeHash: FfiConverterRustBuffer {
29802856 }
29812857}
29822858
2983- private struct FfiConverterDictionaryStringTypeAMValue : FfiConverterRustBuffer {
2984- public static func write( _ value: [ String : AmValue ] , into buf: inout [ UInt8 ] ) {
2985- let len = Int32 ( value. count)
2986- writeInt ( & buf, len)
2987- for (key, value) in value {
2988- FfiConverterString . write ( key, into: & buf)
2989- FfiConverterTypeAMValue . write ( value, into: & buf)
2990- }
2991- }
2992-
2993- public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> [ String : AmValue ] {
2994- let len : Int32 = try readInt ( & buf)
2995- var dict = [ String: AmValue] ( )
2996- dict. reserveCapacity ( Int ( len) )
2997- for _ in 0 ..< len {
2998- let key = try FfiConverterString . read ( from: & buf)
2999- let value = try FfiConverterTypeAMValue . read ( from: & buf)
3000- dict [ key] = value
3001- }
3002- return dict
3003- }
3004- }
3005-
30062859private struct FfiConverterDictionaryStringTypeValue : FfiConverterRustBuffer {
30072860 public static func write( _ value: [ String : Value ] , into buf: inout [ UInt8 ] ) {
30082861 let len = Int32 ( value. count)
@@ -3300,6 +3153,9 @@ private var initializationResult: InitializationResult {
33003153 if uniffi_uniffi_automerge_checksum_method_doc_marks_at ( ) != 57491 {
33013154 return InitializationResult . apiChecksumMismatch
33023155 }
3156+ if uniffi_uniffi_automerge_checksum_method_doc_marks_at_position ( ) != 19243 {
3157+ return InitializationResult . apiChecksumMismatch
3158+ }
33033159 if uniffi_uniffi_automerge_checksum_method_doc_merge ( ) != 8598 {
33043160 return InitializationResult . apiChecksumMismatch
33053161 }
0 commit comments