You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stumped? Well, Uuid isn't the same as UUID, the Swift Foundation class which generates UUIDs. It's a typealias to String, because that's how we serialize UUIDs over the FFI.
The result is that it's trivial to think you've got correct code, since it does indeed compile, but get a strange Rust panic at runtime. The panic looks like this by the way, which makes it sound like a UniFFI error, but it's really a non-obvious error message from the uuid crate.
Failed to convert arg 'route': invalid length: expected length 32 for simple format, found 0
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: uniffi_core::ffi_converter_impls::<impl uniffi_core::ffi_converter_traits::LowerReturn<UT> for core::result::Result<R,E>>::handle_failed_lift
3: std::panicking::try
4: uniffi_core::ffi::rustcalls::rust_call_with_out_status
5: uniffi_core::ffi::rustcalls::rust_call
6: _uniffi_ferrostar_fn_func_location_simulation_from_route
<user code>
Can you spot the issue with this code? It compiles, but will panic when you try to pass the type off to a Rust function at runtime.
Stumped? Well,
Uuid
isn't the same asUUID
, the Swift Foundation class which generates UUIDs. It's atypealias
toString
, because that's how we serialize UUIDs over the FFI.The result is that it's trivial to think you've got correct code, since it does indeed compile, but get a strange Rust panic at runtime. The panic looks like this by the way, which makes it sound like a UniFFI error, but it's really a non-obvious error message from the
uuid
crate.I think we can fix this now by telling UniFFI to convert these to a native type. See https://mozilla.github.io/uniffi-rs/latest/udl/custom_types.html#custom-types-in-the-bindings-code for details on how to accomplish this.
In the meantime, if anyone stumbles across this, here's the correct way to write this:
The text was updated successfully, but these errors were encountered: