Skip to content

Commit e3fbe25

Browse files
authored
Merge pull request #3 from mozilla/release-0.0.2
Cut release version 0.0.2
2 parents 93fa5e1 + e7b028c commit e3fbe25

File tree

6 files changed

+255
-144
lines changed

6 files changed

+255
-144
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ let package = Package(
6161
//
6262
// For release artifacts, reference the MozillaRustComponents as a URL with checksum.
6363
//
64-
url: "https://111955-129966583-gh.circle-artifacts.com/0/dist/MozillaRustComponents.xcframework.zip",
65-
checksum: "f6807476ab4dd850290f4f87850719dfb9601deaee42b202ff8860480bdf1a42"
64+
url: "https://112912-129966583-gh.circle-artifacts.com/0/dist/MozillaRustComponents.xcframework.zip",
65+
checksum: "a67cfdab5e9a52eeb93435b20a4fc2813fe0486113c6eab5d7fa77fcbcb4fa07"
6666
//
6767
// For local testing, you can point at an (unzipped) XCFramework that's part of the repo.
6868
// Note that you have to actually check it in and make a tag for it to work correctly.

generated/crashtest/crashtest.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ private extension RustBuffer {
1414
// Allocate a new buffer, copying the contents of a `UInt8` array.
1515
init(bytes: [UInt8]) {
1616
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) }
1818
}
1919
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
2020
}
2121

2222
// Frees the buffer in place.
2323
// The buffer must not be used after this is called.
2424
func deallocate() {
25-
try! rustCall { ffi_crashtest_7e7a_rustbuffer_free(self, $0) }
25+
try! rustCall { ffi_crashtest_f229_rustbuffer_free(self, $0) }
2626
}
2727
}
2828

@@ -204,7 +204,7 @@ extension String: ViaFfi {
204204

205205
fileprivate static func lift(_ v: FfiType) throws -> Self {
206206
defer {
207-
try! rustCall { ffi_crashtest_7e7a_rustbuffer_free(v, $0) }
207+
try! rustCall { ffi_crashtest_f229_rustbuffer_free(v, $0) }
208208
}
209209
if v.data == nil {
210210
return String()
@@ -220,7 +220,7 @@ extension String: ViaFfi {
220220
// The swift string gives us a trailing null byte, we don't want it.
221221
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
222222
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) }
224224
}
225225
}
226226
}
@@ -283,22 +283,27 @@ private extension RustCallStatus {
283283
}
284284

285285
public enum CrashTestError {
286-
case ErrorFromTheRustCode
286+
// Simple error enums only carry a message
287+
case ErrorFromTheRustCode(message: String)
287288
}
288289

289290
extension CrashTestError: ViaFfiUsingByteBuffer, ViaFfi {
290291
fileprivate static func read(from buf: Reader) throws -> CrashTestError {
291292
let variant: Int32 = try buf.readInt()
292293
switch variant {
293-
case 1: return .ErrorFromTheRustCode
294+
case 1: return .ErrorFromTheRustCode(
295+
message: try String.read(from: buf)
296+
)
297+
294298
default: throw UniffiInternalError.unexpectedEnumCase
295299
}
296300
}
297301

298302
fileprivate func write(into buf: Writer) {
299303
switch self {
300-
case .ErrorFromTheRustCode:
304+
case let .ErrorFromTheRustCode(message):
301305
buf.writeInt(Int32(1))
306+
message.write(into: buf)
302307
}
303308
}
304309
}
@@ -348,22 +353,22 @@ public func triggerRustAbort() {
348353
try!
349354

350355
rustCall {
351-
crashtest_7e7a_trigger_rust_abort($0)
356+
crashtest_f229_trigger_rust_abort($0)
352357
}
353358
}
354359

355360
public func triggerRustPanic() {
356361
try!
357362

358363
rustCall {
359-
crashtest_7e7a_trigger_rust_panic($0)
364+
crashtest_f229_trigger_rust_panic($0)
360365
}
361366
}
362367

363368
public func triggerRustError() throws {
364369
try
365370

366371
rustCallWithError(CrashTestError.self) {
367-
crashtest_7e7a_trigger_rust_error($0)
372+
crashtest_f229_trigger_rust_error($0)
368373
}
369374
}

generated/crashtest/crashtestFFI.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,31 @@ typedef struct RustCallStatus {
4444
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V3 in this file. ⚠️
4545
#endif // def UNIFFI_SHARED_H
4646

47-
void crashtest_7e7a_trigger_rust_abort(
47+
void crashtest_f229_trigger_rust_abort(
4848

4949
RustCallStatus *_Nonnull out_status
5050
);
51-
void crashtest_7e7a_trigger_rust_panic(
51+
void crashtest_f229_trigger_rust_panic(
5252

5353
RustCallStatus *_Nonnull out_status
5454
);
55-
void crashtest_7e7a_trigger_rust_error(
55+
void crashtest_f229_trigger_rust_error(
5656

5757
RustCallStatus *_Nonnull out_status
5858
);
59-
RustBuffer ffi_crashtest_7e7a_rustbuffer_alloc(
59+
RustBuffer ffi_crashtest_f229_rustbuffer_alloc(
6060
int32_t size,
6161
RustCallStatus *_Nonnull out_status
6262
);
63-
RustBuffer ffi_crashtest_7e7a_rustbuffer_from_bytes(
63+
RustBuffer ffi_crashtest_f229_rustbuffer_from_bytes(
6464
ForeignBytes bytes,
6565
RustCallStatus *_Nonnull out_status
6666
);
67-
void ffi_crashtest_7e7a_rustbuffer_free(
67+
void ffi_crashtest_f229_rustbuffer_free(
6868
RustBuffer buf,
6969
RustCallStatus *_Nonnull out_status
7070
);
71-
RustBuffer ffi_crashtest_7e7a_rustbuffer_reserve(
71+
RustBuffer ffi_crashtest_f229_rustbuffer_reserve(
7272
RustBuffer buf,int32_t additional,
7373
RustCallStatus *_Nonnull out_status
7474
);

0 commit comments

Comments
 (0)