use record exported types
This commit is contained in:
parent
25e6752583
commit
74b0cab9b5
|
@ -1,20 +1,18 @@
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
import Hello
|
import Hello
|
||||||
|
import UIKit
|
||||||
|
|
||||||
class ViewController: UIViewController {
|
class ViewController: UIViewController {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
print(rustGreeting(to: "Bob"))
|
print(rustGreeting(to: "Bob"))
|
||||||
print(Hello.add(a: 1, b: 2))
|
print(Hello.add(a: 1, b: 2))
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
let str = await Hello.sayAfter(ms: 1500, who: "Async")
|
let str = await Hello.sayAfter(ms: 1500, who: "Async")
|
||||||
print(str)
|
print(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(Hello.addObj(a: RustDemoObj(value: 1), b: RustDemoObj(value: 2)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,3 +57,15 @@ pub async fn say_after(ms: u64, who: String) -> String {
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
format!("Hello, {who}!")
|
format!("Hello, {who}!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(uniffi::Record)]
|
||||||
|
pub struct RustDemoObj {
|
||||||
|
pub value: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[uniffi::export]
|
||||||
|
pub fn add_obj(a: &RustDemoObj, b: &RustDemoObj) -> RustDemoObj {
|
||||||
|
RustDemoObj {
|
||||||
|
value: a.value + b.value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue