api work
This commit is contained in:
parent
25b776f5a1
commit
d660d86884
@ -1,5 +1,6 @@
|
|||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use async_std::sync::Mutex as AsyncMutex;
|
use async_std::sync::Mutex as AsyncMutex;
|
||||||
|
use cfg_if::*;
|
||||||
use flutter_rust_bridge::*;
|
use flutter_rust_bridge::*;
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -118,12 +119,25 @@ pub struct VeilidConfig {
|
|||||||
pub network__leases__max_client_relay_leases: u32,
|
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<dyn std::any::Any + 'static>;
|
||||||
|
} else {
|
||||||
|
type ConfigReturn = Box<dyn std::any::Any + Send + 'static>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl VeilidConfig {
|
impl VeilidConfig {
|
||||||
pub fn get_by_str(
|
pub fn get_by_str(&self, key: &str) -> std::result::Result<ConfigReturn, String> {
|
||||||
&self,
|
let out: ConfigReturn = match key {
|
||||||
key: &str,
|
|
||||||
) -> std::result::Result<Box<dyn std::any::Any + Send + 'static>, String> {
|
|
||||||
let out: Box<dyn core::any::Any + Send> = match key {
|
|
||||||
"program_name" => Box::new(self.program_name.clone()),
|
"program_name" => Box::new(self.program_name.clone()),
|
||||||
"namespace" => Box::new(self.veilid_namespace.clone()),
|
"namespace" => Box::new(self.veilid_namespace.clone()),
|
||||||
"api_log_level" => Box::new(self.api_log_level.to_config_log_level()),
|
"api_log_level" => Box::new(self.api_log_level.to_config_log_level()),
|
||||||
|
@ -579,21 +579,3 @@ pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct)
|
|||||||
let _ = support::vec_from_leak_ptr(val.ptr, val.len);
|
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,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
|||||||
mod api;
|
mod api;
|
||||||
mod bridge_generated;
|
mod bridge_generated;
|
||||||
|
|
||||||
use cfg_if::*;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user