diff --git a/veilid-flutter/rust/src/api.rs b/veilid-flutter/rust/src/api.rs index 502f9e0c..8013f9d3 100644 --- a/veilid-flutter/rust/src/api.rs +++ b/veilid-flutter/rust/src/api.rs @@ -1,5 +1,6 @@ use anyhow::*; use async_std::sync::Mutex as AsyncMutex; +use cfg_if::*; use flutter_rust_bridge::*; use log::*; use std::fmt; @@ -118,12 +119,25 @@ pub struct VeilidConfig { pub network__leases__max_client_relay_leases: u32, } +cfg_if! { + if #[cfg(target_arch="wasm32")] { + + } else { + + } +} + +cfg_if! { + if #[cfg(target_arch="wasm32")] { + type ConfigReturn = Box; + } else { + type ConfigReturn = Box; + } +} + impl VeilidConfig { - pub fn get_by_str( - &self, - key: &str, - ) -> std::result::Result, String> { - let out: Box = match key { + pub fn get_by_str(&self, key: &str) -> std::result::Result { + let out: ConfigReturn = match key { "program_name" => Box::new(self.program_name.clone()), "namespace" => Box::new(self.veilid_namespace.clone()), "api_log_level" => Box::new(self.api_log_level.to_config_log_level()), diff --git a/veilid-flutter/rust/src/bridge_generated.rs b/veilid-flutter/rust/src/bridge_generated.rs index 0fd4a9f2..4588a19c 100644 --- a/veilid-flutter/rust/src/bridge_generated.rs +++ b/veilid-flutter/rust/src/bridge_generated.rs @@ -579,21 +579,3 @@ pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) let _ = support::vec_from_leak_ptr(val.ptr, val.len); } } - - // ----------- DUMMY CODE FOR BINDGEN ---------- - - // copied from: allo-isolate - pub type DartPort = i64; - pub type DartPostCObjectFnType = unsafe extern "C" fn(port_id: DartPort, message: *mut std::ffi::c_void) -> bool; - #[no_mangle] pub unsafe extern "C" fn store_dart_post_cobject(ptr: DartPostCObjectFnType) { panic!("dummy code") } - - // copied from: frb_rust::support.rs - #[repr(C)] - pub struct WireSyncReturnStruct { - pub ptr: *mut u8, - pub len: i32, - pub success: bool, - } - - // --------------------------------------------- - \ No newline at end of file diff --git a/veilid-flutter/rust/src/lib.rs b/veilid-flutter/rust/src/lib.rs index 459c27aa..5cf58a4e 100644 --- a/veilid-flutter/rust/src/lib.rs +++ b/veilid-flutter/rust/src/lib.rs @@ -1,8 +1,6 @@ mod api; mod bridge_generated; -use cfg_if::*; - #[cfg(target_os = "android")] use jni::{objects::JClass, objects::JObject, JNIEnv};