@@ -473,7 +473,7 @@ public protocol FirefoxAccountProtocol: AnyObject {
473
473
* If a device on the account has registered the [`CloseTabs`](DeviceCapability::CloseTabs)
474
474
* capability, this method can be used to close its tabs.
475
475
*/
476
- func closeTabs( targetDeviceId: String , urls: [ String ] ) throws
476
+ func closeTabs( targetDeviceId: String , urls: [ String ] ) throws -> CloseTabsResult
477
477
478
478
func completeOauthFlow( code: String , state: String ) throws
479
479
@@ -642,11 +642,12 @@ open class FirefoxAccount:
642
642
* If a device on the account has registered the [`CloseTabs`](DeviceCapability::CloseTabs)
643
643
* capability, this method can be used to close its tabs.
644
644
*/
645
- open func closeTabs( targetDeviceId: String , urls: [ String ] ) throws { try rustCallWithError ( FfiConverterTypeFxaError . lift) {
646
- uniffi_fxa_client_fn_method_firefoxaccount_close_tabs ( self . uniffiClonePointer ( ) ,
647
- FfiConverterString . lower ( targetDeviceId) ,
648
- FfiConverterSequenceString . lower ( urls) , $0)
649
- }
645
+ open func closeTabs( targetDeviceId: String , urls: [ String ] ) throws -> CloseTabsResult {
646
+ return try FfiConverterTypeCloseTabsResult . lift ( rustCallWithError ( FfiConverterTypeFxaError . lift) {
647
+ uniffi_fxa_client_fn_method_firefoxaccount_close_tabs ( self . uniffiClonePointer ( ) ,
648
+ FfiConverterString . lower ( targetDeviceId) ,
649
+ FfiConverterSequenceString . lower ( urls) , $0)
650
+ } )
650
651
}
651
652
652
653
open func completeOauthFlow( code: String , state: String ) throws { try rustCallWithError ( FfiConverterTypeFxaError . lift) {
@@ -2141,6 +2142,77 @@ public func FfiConverterTypeAccountEvent_lower(_ value: AccountEvent) -> RustBuf
2141
2142
2142
2143
extension AccountEvent : Equatable , Hashable { }
2143
2144
2145
+ // Note that we don't yet support `indirect` for enums.
2146
+ // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
2147
+ /**
2148
+ * The result of invoking a "close tabs" command.
2149
+ *
2150
+ * If [`FirefoxAccount::close_tabs`] is called with more URLs than can fit
2151
+ * into a single command payload, the URLs will be chunked and sent in
2152
+ * multiple commands.
2153
+ *
2154
+ * Chunking breaks the atomicity of a "close tabs" command, but
2155
+ * reduces the number of these commands that FxA sends to other devices.
2156
+ * This is critical for platforms like iOS, where every command triggers a
2157
+ * push message that must show a user-visible notification.
2158
+ */
2159
+
2160
+ public enum CloseTabsResult {
2161
+ /**
2162
+ * All URLs passed to [`FirefoxAccount::close_tabs`] were chunked and sent
2163
+ * in one or more device commands.
2164
+ */
2165
+ case ok
2166
+ /**
2167
+ * One or more URLs passed to [`FirefoxAccount::close_tabs`] couldn't be sent
2168
+ * in a device command. The caller can assume that:
2169
+ *
2170
+ * 1. Any URL in the returned list of `urls` was not sent, and
2171
+ * should be retried.
2172
+ * 2. All other URLs that were passed to [`FirefoxAccount::close_tabs`], and
2173
+ * that are _not_ in the list of `urls`, were chunked and sent.
2174
+ */
2175
+ case tabsNotClosed( urls: [ String ]
2176
+ )
2177
+ }
2178
+
2179
+ public struct FfiConverterTypeCloseTabsResult : FfiConverterRustBuffer {
2180
+ typealias SwiftType = CloseTabsResult
2181
+
2182
+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> CloseTabsResult {
2183
+ let variant : Int32 = try readInt ( & buf)
2184
+ switch variant {
2185
+ case 1 : return . ok
2186
+
2187
+ case 2 : return try . tabsNotClosed( urls: FfiConverterSequenceString . read ( from: & buf)
2188
+ )
2189
+
2190
+ default : throw UniffiInternalError . unexpectedEnumCase
2191
+ }
2192
+ }
2193
+
2194
+ public static func write( _ value: CloseTabsResult , into buf: inout [ UInt8 ] ) {
2195
+ switch value {
2196
+ case . ok:
2197
+ writeInt ( & buf, Int32 ( 1 ) )
2198
+
2199
+ case let . tabsNotClosed( urls) :
2200
+ writeInt ( & buf, Int32 ( 2 ) )
2201
+ FfiConverterSequenceString . write ( urls, into: & buf)
2202
+ }
2203
+ }
2204
+ }
2205
+
2206
+ public func FfiConverterTypeCloseTabsResult_lift( _ buf: RustBuffer ) throws -> CloseTabsResult {
2207
+ return try FfiConverterTypeCloseTabsResult . lift ( buf)
2208
+ }
2209
+
2210
+ public func FfiConverterTypeCloseTabsResult_lower( _ value: CloseTabsResult ) -> RustBuffer {
2211
+ return FfiConverterTypeCloseTabsResult . lower ( value)
2212
+ }
2213
+
2214
+ extension CloseTabsResult : Equatable , Hashable { }
2215
+
2144
2216
// Note that we don't yet support `indirect` for enums.
2145
2217
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
2146
2218
@@ -3100,7 +3172,7 @@ private var initializationResult: InitializationResult {
3100
3172
if uniffi_fxa_client_checksum_method_firefoxaccount_clear_device_name ( ) != 42324 {
3101
3173
return InitializationResult . apiChecksumMismatch
3102
3174
}
3103
- if uniffi_fxa_client_checksum_method_firefoxaccount_close_tabs ( ) != 64219 {
3175
+ if uniffi_fxa_client_checksum_method_firefoxaccount_close_tabs ( ) != 55044 {
3104
3176
return InitializationResult . apiChecksumMismatch
3105
3177
}
3106
3178
if uniffi_fxa_client_checksum_method_firefoxaccount_complete_oauth_flow ( ) != 41338 {
0 commit comments