@@ -14,15 +14,15 @@ private extension RustBuffer {
14
14
// Allocate a new buffer, copying the contents of a `UInt8` array.
15
15
init ( bytes: [ UInt8 ] ) {
16
16
let rbuf = bytes. withUnsafeBufferPointer { ptr in
17
- try ! rustCall { ffi_crashtest_7e7a_rustbuffer_from_bytes ( ForeignBytes ( bufferPointer: ptr) , $0) }
17
+ try ! rustCall { ffi_crashtest_f229_rustbuffer_from_bytes ( ForeignBytes ( bufferPointer: ptr) , $0) }
18
18
}
19
19
self . init ( capacity: rbuf. capacity, len: rbuf. len, data: rbuf. data)
20
20
}
21
21
22
22
// Frees the buffer in place.
23
23
// The buffer must not be used after this is called.
24
24
func deallocate( ) {
25
- try ! rustCall { ffi_crashtest_7e7a_rustbuffer_free ( self , $0) }
25
+ try ! rustCall { ffi_crashtest_f229_rustbuffer_free ( self , $0) }
26
26
}
27
27
}
28
28
@@ -204,7 +204,7 @@ extension String: ViaFfi {
204
204
205
205
fileprivate static func lift( _ v: FfiType ) throws -> Self {
206
206
defer {
207
- try ! rustCall { ffi_crashtest_7e7a_rustbuffer_free ( v, $0) }
207
+ try ! rustCall { ffi_crashtest_f229_rustbuffer_free ( v, $0) }
208
208
}
209
209
if v. data == nil {
210
210
return String ( )
@@ -220,7 +220,7 @@ extension String: ViaFfi {
220
220
// The swift string gives us a trailing null byte, we don't want it.
221
221
let buf = UnsafeBufferPointer ( rebasing: ptr. prefix ( upTo: ptr. count - 1 ) )
222
222
let bytes = ForeignBytes ( bufferPointer: buf)
223
- return try ! rustCall { ffi_crashtest_7e7a_rustbuffer_from_bytes ( bytes, $0) }
223
+ return try ! rustCall { ffi_crashtest_f229_rustbuffer_from_bytes ( bytes, $0) }
224
224
}
225
225
}
226
226
}
@@ -283,22 +283,27 @@ private extension RustCallStatus {
283
283
}
284
284
285
285
public enum CrashTestError {
286
- case ErrorFromTheRustCode
286
+ // Simple error enums only carry a message
287
+ case ErrorFromTheRustCode( message: String )
287
288
}
288
289
289
290
extension CrashTestError : ViaFfiUsingByteBuffer , ViaFfi {
290
291
fileprivate static func read( from buf: Reader ) throws -> CrashTestError {
291
292
let variant : Int32 = try buf. readInt ( )
292
293
switch variant {
293
- case 1 : return . ErrorFromTheRustCode
294
+ case 1 : return . ErrorFromTheRustCode(
295
+ message: try String . read ( from: buf)
296
+ )
297
+
294
298
default : throw UniffiInternalError . unexpectedEnumCase
295
299
}
296
300
}
297
301
298
302
fileprivate func write( into buf: Writer ) {
299
303
switch self {
300
- case . ErrorFromTheRustCode:
304
+ case let . ErrorFromTheRustCode( message ) :
301
305
buf. writeInt ( Int32 ( 1 ) )
306
+ message. write ( into: buf)
302
307
}
303
308
}
304
309
}
@@ -348,22 +353,22 @@ public func triggerRustAbort() {
348
353
try !
349
354
350
355
rustCall {
351
- crashtest_7e7a_trigger_rust_abort ( $0)
356
+ crashtest_f229_trigger_rust_abort ( $0)
352
357
}
353
358
}
354
359
355
360
public func triggerRustPanic( ) {
356
361
try !
357
362
358
363
rustCall {
359
- crashtest_7e7a_trigger_rust_panic ( $0)
364
+ crashtest_f229_trigger_rust_panic ( $0)
360
365
}
361
366
}
362
367
363
368
public func triggerRustError( ) throws {
364
369
try
365
370
366
371
rustCallWithError ( CrashTestError . self) {
367
- crashtest_7e7a_trigger_rust_error ( $0)
372
+ crashtest_f229_trigger_rust_error ( $0)
368
373
}
369
374
}
0 commit comments