Open
Description
This seems to be supported, but I'm getting this error:
error[E0605]: non-primitive cast: `__swift_bridge__MyError` as `*mut c_void`
--> src/lib.rs:6:1
|
6 | #[swift_bridge::bridge]
| ^^^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
= note: this error originates in the attribute macro `swift_bridge::bridge` (in Nightly builds, run with -Z macro-backtrace for more info)
Source:
#![feature(extern_types)]
use crate::ffi::*;
use std::collections::HashMap;
#[swift_bridge::bridge]
mod ffi {
#[swift_bridge(swift_repr = "struct")]
pub struct MyIpAddress {
pub origin: String,
}
#[swift_bridge(swift_repr = "struct")]
pub struct MyError {}
extern "Rust" {
// type MyIpAddress;
// type MyError;
fn get_my_ip_from_rust() -> Result<MyIpAddress, MyError>;
}
}
fn get_my_ip_from_rust() -> Result<MyIpAddress, MyError> {
println!("Starting HTTP request from the Rust side...");
let origin = reqwest::blocking::get("https://httpbin.org/ip")
.unwrap()
.json::<HashMap<String, String>>()
.unwrap()
.remove("origin")
.unwrap();
println!("HTTP request complete. Returning the value to Swift...");
Ok(MyIpAddress { origin })
}
Am I missing something?