#[doc(hidden)]
pub use uniffi;
#[macro_export]
macro_rules! export_uniffi_core {
($app:ty) => {
::uniffi::setup_scaffolding!();
#[derive(::uniffi::Object)]
pub struct Core {
inner: ::std::sync::Mutex<$crate::Runtime<$app>>,
}
impl Core {
fn lock(&self) -> ::std::sync::MutexGuard<'_, $crate::Runtime<$app>> {
self.inner
.lock()
.unwrap_or_else(::std::sync::PoisonError::into_inner)
}
}
#[expect(
clippy::needless_pass_by_value,
reason = "UniFFI hands over owned values; the exported signatures cannot borrow"
)]
#[::uniffi::export]
impl Core {
#[uniffi::constructor]
#[must_use]
pub fn new(boot: Vec<u8>) -> ::std::sync::Arc<Self> {
::std::sync::Arc::new(Self {
inner: ::std::sync::Mutex::new($crate::Runtime::<$app>::new(&boot)),
})
}
#[must_use]
pub fn dispatch(&self, input: Vec<u8>) -> Vec<u8> {
$crate::Bridge::dispatch(&mut *self.lock(), &input)
}
#[must_use]
pub fn pointer(&self, phase: u8, x: f32, y: f32, at_ms: f64) -> u32 {
$crate::Bridge::pointer(&mut *self.lock(), phase, x, y, at_ms)
}
#[must_use]
pub fn view(&self, key: String) -> Vec<u8> {
$crate::Bridge::view(&*self.lock(), &key)
}
#[must_use]
pub fn provide_blob(&self, name: String, bytes: Vec<u8>) -> Vec<u8> {
$crate::Bridge::provide_blob(&mut *self.lock(), &name, &bytes)
}
}
#[must_use]
#[::uniffi::export]
pub fn bridge_protocol() -> u32 {
u32::try_from($crate::BRIDGE_PROTOCOL).unwrap_or(0)
}
};
}