30 lines
821 B
Rust
30 lines
821 B
Rust
|
|
macro_rules! wrap_uniffi_object {
|
|
($orig_t:ident, $new_t:ident) => {
|
|
#[derive(uniffi::Object)]
|
|
pub struct $new_t {
|
|
pub(crate) actual: std::sync::RwLock<servicepoint::$orig_t>,
|
|
}
|
|
|
|
impl $new_t {
|
|
pub(crate) fn internal_new(actual: servicepoint::$orig_t) -> Arc<Self> {
|
|
Arc::new(Self {
|
|
actual: std::sync::RwLock::new(actual),
|
|
})
|
|
}
|
|
}
|
|
|
|
#[uniffi::export]
|
|
impl $new_t {
|
|
#[uniffi::constructor]
|
|
pub fn clone(other: &Arc<Self>) -> Arc<Self> {
|
|
Self::internal_new(other.actual.read().unwrap().clone())
|
|
}
|
|
}
|
|
};
|
|
($t:ident) => {
|
|
wrap_uniffi_object!($t, $t);
|
|
};
|
|
}
|
|
|
|
pub(crate) use wrap_uniffi_object; |