From e302b764d0b91e5d1ded4c6653c4bc7ce15e1432 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Tue, 29 Aug 2023 15:15:47 -0500 Subject: [PATCH] docs and tests work --- veilid-cli/src/main.rs | 2 + veilid-cli/src/tools.rs | 3 +- veilid-core/Cargo.toml | 6 +- veilid-core/run_tests.sh | 2 +- veilid-core/run_windows_tests.bat | 2 +- veilid-core/src/crypto/mod.rs | 1 + .../intf/native/network_interfaces/netlink.rs | 2 + veilid-core/src/intf/native/system.rs | 2 + veilid-core/src/lib.rs | 17 +++++ veilid-core/src/network_manager/mod.rs | 1 + .../src/network_manager/native/network_tcp.rs | 4 + .../src/network_manager/native/network_udp.rs | 6 ++ .../native/protocol/sockets.rs | 4 + .../network_manager/native/protocol/tcp.rs | 4 +- .../src/network_manager/native/protocol/ws.rs | 2 + veilid-core/src/table_store/table_store.rs | 4 +- veilid-core/src/tests/native/mod.rs | 26 ++++--- veilid-core/src/veilid_api/api.rs | 73 +++++++++++++++---- veilid-core/src/veilid_api/mod.rs | 5 +- veilid-core/src/veilid_api/tests/mod.rs | 1 + veilid-flutter/rust/src/dart_ffi.rs | 41 +++-------- veilid-flutter/rust/src/tools.rs | 3 +- veilid-server/src/client_api.rs | 6 +- veilid-server/src/tools.rs | 3 +- veilid-server/src/veilid_logs.rs | 2 + veilid-tools/src/lib.rs | 2 +- veilid-wasm/Cargo.toml | 6 +- 27 files changed, 156 insertions(+), 74 deletions(-) diff --git a/veilid-cli/src/main.rs b/veilid-cli/src/main.rs index 02c78631..11f0ebde 100644 --- a/veilid-cli/src/main.rs +++ b/veilid-cli/src/main.rs @@ -169,6 +169,8 @@ fn main() -> Result<(), String> { } else if #[cfg(feature="rt-tokio")] { // Wait for ui and connection to complete let _ = tokio::join!(ui_future, connection_future); + } else { + compile_error!("needs executor implementation") } } }); diff --git a/veilid-cli/src/tools.rs b/veilid-cli/src/tools.rs index 7e6fe04c..2223a935 100644 --- a/veilid-cli/src/tools.rs +++ b/veilid-cli/src/tools.rs @@ -19,7 +19,8 @@ cfg_if! { let local = tokio::task::LocalSet::new(); local.block_on(&rt, f) } - + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-core/Cargo.toml b/veilid-core/Cargo.toml index 5aa252cf..5f4128c5 100644 --- a/veilid-core/Cargo.toml +++ b/veilid-core/Cargo.toml @@ -13,6 +13,7 @@ crate-type = ["cdylib", "staticlib", "rlib"] # Common features default = ["enable-crypto-vld0", "rt-tokio"] +default-wasm = ["enable-crypto-vld0"] rt-async-std = [ "async-std", "async-std-resolver", @@ -32,7 +33,6 @@ rt-tokio = [ "rtnetlink/tokio_socket", "veilid-tools/rt-tokio", ] -rt-wasm-bindgen = ["veilid-tools/rt-wasm-bindgen", "async_executors/bindgen"] # Crypto support features enable-crypto-vld0 = [] @@ -174,6 +174,10 @@ socket2 = { version = "0.5.3", features = ["all"] } # Dependencies for WASM builds only [target.'cfg(target_arch = "wasm32")'.dependencies] +veilid-tools = { path = "../veilid-tools", default-features = false, features = [ + "rt-wasm-bindgen", +] } + # Tools getrandom = { version = "0.2.4", features = ["js"] } diff --git a/veilid-core/run_tests.sh b/veilid-core/run_tests.sh index 713de207..f0e5af9f 100755 --- a/veilid-core/run_tests.sh +++ b/veilid-core/run_tests.sh @@ -59,7 +59,7 @@ elif [[ "$1" == "android" ]]; then popd >/dev/null else - cargo test --features=rt-tokio + cargo test cargo test --features=rt-async-std fi popd 2>/dev/null \ No newline at end of file diff --git a/veilid-core/run_windows_tests.bat b/veilid-core/run_windows_tests.bat index 7ab6b2a3..7a48beb4 100644 --- a/veilid-core/run_windows_tests.bat +++ b/veilid-core/run_windows_tests.bat @@ -1,4 +1,4 @@ @echo off -cargo test --features=rt-tokio -- --nocapture +cargo test -- --nocapture cargo test --features=rt-async-std -- --nocapture diff --git a/veilid-core/src/crypto/mod.rs b/veilid-core/src/crypto/mod.rs index 0b2c63ec..618cff3f 100644 --- a/veilid-core/src/crypto/mod.rs +++ b/veilid-core/src/crypto/mod.rs @@ -7,6 +7,7 @@ mod types; pub mod crypto_system; #[cfg(feature = "enable-crypto-none")] pub mod none; +#[doc(hidden)] pub mod tests; #[cfg(feature = "enable-crypto-vld0")] pub mod vld0; diff --git a/veilid-core/src/intf/native/network_interfaces/netlink.rs b/veilid-core/src/intf/native/network_interfaces/netlink.rs index 4b0f057c..3c757637 100644 --- a/veilid-core/src/intf/native/network_interfaces/netlink.rs +++ b/veilid-core/src/intf/native/network_interfaces/netlink.rs @@ -17,6 +17,8 @@ cfg_if! { use netlink_sys::{SmolSocket as RTNetLinkSocket}; } else if #[cfg(feature="rt-tokio")] { use netlink_sys::{TokioSocket as RTNetLinkSocket}; + } else { + compile_error!("needs executor implementation") } } use std::convert::TryInto; diff --git a/veilid-core/src/intf/native/system.rs b/veilid-core/src/intf/native/system.rs index 96b75ae8..11d9e47c 100644 --- a/veilid-core/src/intf/native/system.rs +++ b/veilid-core/src/intf/native/system.rs @@ -36,6 +36,8 @@ cfg_if! { pub async fn resolver_from_system_conf() -> Result { AsyncResolver::tokio_from_system_conf() } + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-core/src/lib.rs b/veilid-core/src/lib.rs index 6c707b24..54ce58bd 100644 --- a/veilid-core/src/lib.rs +++ b/veilid-core/src/lib.rs @@ -1,3 +1,14 @@ +//! The Veilid Framework +//! +//! Core library used to create a Veilid node and operate veilid services as part of an application. +//! +//! `veilid-core` contains all of the core logic for Veilid and can be used in mobile applications as well as desktop +//! and in-browser WebAssembly apps. +//! +//! The public API is accessed by getting a [VeilidAPI] object via a call to [api_startup] or [api_startup_json]. +//! +//! From there, a [RoutingContext] object can get you access to public and private routed operations. +//! #![deny(clippy::all)] #![deny(unused_must_use)] #![recursion_limit = "256"] @@ -41,15 +52,20 @@ pub use self::veilid_config::*; pub use self::veilid_layer_filter::*; pub use veilid_tools as tools; +/// The on-the-wire serialization format for Veilid RPC pub mod veilid_capnp { include!(concat!(env!("OUT_DIR"), "/proto/veilid_capnp.rs")); } +#[doc(hidden)] pub mod tests; +/// Return the cargo package version of veilid-core in string format pub fn veilid_version_string() -> String { env!("CARGO_PKG_VERSION").to_owned() } + +/// Return the cargo package version of veilid-core in tuple format pub fn veilid_version() -> (u32, u32, u32) { ( u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap(), @@ -90,6 +106,7 @@ pub static DEFAULT_LOG_IGNORE_LIST: [&str; 23] = [ use cfg_if::*; use enumset::*; use eyre::{bail, eyre, Report as EyreReport, Result as EyreResult, WrapErr}; +#[allow(unused_imports)] use futures_util::stream::{FuturesOrdered, FuturesUnordered}; use parking_lot::*; use schemars::{schema_for, JsonSchema}; diff --git a/veilid-core/src/network_manager/mod.rs b/veilid-core/src/network_manager/mod.rs index aedd09f0..2bac8c5e 100644 --- a/veilid-core/src/network_manager/mod.rs +++ b/veilid-core/src/network_manager/mod.rs @@ -16,6 +16,7 @@ mod stats; mod tasks; mod types; +#[doc(hidden)] pub mod tests; //////////////////////////////////////////////////////////////////////////////////////// diff --git a/veilid-core/src/network_manager/native/network_tcp.rs b/veilid-core/src/network_manager/native/network_tcp.rs index 2ea1fbf7..c6112e6c 100644 --- a/veilid-core/src/network_manager/native/network_tcp.rs +++ b/veilid-core/src/network_manager/native/network_tcp.rs @@ -264,6 +264,8 @@ impl Network { } else if #[cfg(feature="rt-tokio")] { std_listener.set_nonblocking(true).expect("failed to set nonblocking"); let listener = TcpListener::from_std(std_listener).wrap_err("failed to create tokio tcp listener")?; + } else { + compile_error!("needs executor implementation") } } @@ -291,6 +293,8 @@ impl Network { let incoming_stream = listener.incoming(); } else if #[cfg(feature="rt-tokio")] { let incoming_stream = tokio_stream::wrappers::TcpListenerStream::new(listener); + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-core/src/network_manager/native/network_udp.rs b/veilid-core/src/network_manager/native/network_udp.rs index 4ea508d9..3a0e6c17 100644 --- a/veilid-core/src/network_manager/native/network_udp.rs +++ b/veilid-core/src/network_manager/native/network_udp.rs @@ -136,6 +136,8 @@ impl Network { } else if #[cfg(feature="rt-tokio")] { std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking"); let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make outbound v4 tokio udpsocket")?; + } else { + compile_error!("needs executor implementation") } } let socket_arc = Arc::new(udp_socket); @@ -160,6 +162,8 @@ impl Network { } else if #[cfg(feature="rt-tokio")] { std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking"); let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make outbound v6 tokio udpsocket")?; + } else { + compile_error!("needs executor implementation") } } let socket_arc = Arc::new(udp_socket); @@ -190,6 +194,8 @@ impl Network { } else if #[cfg(feature="rt-tokio")] { std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking"); let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make inbound tokio udpsocket")?; + } else { + compile_error!("needs executor implementation") } } let socket_arc = Arc::new(udp_socket); diff --git a/veilid-core/src/network_manager/native/protocol/sockets.rs b/veilid-core/src/network_manager/native/protocol/sockets.rs index 5750513e..1b125d6d 100644 --- a/veilid-core/src/network_manager/native/protocol/sockets.rs +++ b/veilid-core/src/network_manager/native/protocol/sockets.rs @@ -8,6 +8,8 @@ cfg_if! { } else if #[cfg(feature="rt-tokio")] { pub use tokio::net::{TcpStream, TcpListener, UdpSocket}; pub use tokio_util::compat::*; + } else { + compile_error!("needs executor implementation") } } @@ -224,6 +226,8 @@ pub async fn nonblocking_connect( Ok(TimeoutOr::value(TcpStream::from(async_stream.into_inner()?))) } else if #[cfg(feature="rt-tokio")] { Ok(TimeoutOr::value(TcpStream::from_std(async_stream.into_inner()?)?)) + } else { + compile_error!("needs executor implementation") } } } diff --git a/veilid-core/src/network_manager/native/protocol/tcp.rs b/veilid-core/src/network_manager/native/protocol/tcp.rs index f095441f..edd2a6c9 100644 --- a/veilid-core/src/network_manager/native/protocol/tcp.rs +++ b/veilid-core/src/network_manager/native/protocol/tcp.rs @@ -36,7 +36,9 @@ impl RawTcpNetworkConnection { // self.tcp_stream.get_mut() // .shutdown() // .await - // } + // } else { + // compile_error!("needs executor implementation") + // } // } // } diff --git a/veilid-core/src/network_manager/native/protocol/ws.rs b/veilid-core/src/network_manager/native/protocol/ws.rs index e724e4a0..cc864882 100644 --- a/veilid-core/src/network_manager/native/protocol/ws.rs +++ b/veilid-core/src/network_manager/native/protocol/ws.rs @@ -14,6 +14,8 @@ cfg_if! { pub type WebsocketNetworkConnectionWSS = WebsocketNetworkConnection>>; pub type WebsocketNetworkConnectionWS = WebsocketNetworkConnection>; + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-core/src/table_store/table_store.rs b/veilid-core/src/table_store/table_store.rs index 04a9206f..3f5e9821 100644 --- a/veilid-core/src/table_store/table_store.rs +++ b/veilid-core/src/table_store/table_store.rs @@ -164,7 +164,7 @@ impl TableStore { self.flush().await; } - pub fn maybe_unprotect_device_encryption_key( + pub(crate) fn maybe_unprotect_device_encryption_key( &self, dek_bytes: &[u8], device_encryption_key_password: &str, @@ -218,7 +218,7 @@ impl TableStore { )) } - pub fn maybe_protect_device_encryption_key( + pub(crate) fn maybe_protect_device_encryption_key( &self, dek: TypedSharedSecret, device_encryption_key_password: &str, diff --git a/veilid-core/src/tests/native/mod.rs b/veilid-core/src/tests/native/mod.rs index bc995c68..bcb7d701 100644 --- a/veilid-core/src/tests/native/mod.rs +++ b/veilid-core/src/tests/native/mod.rs @@ -41,17 +41,21 @@ pub async fn run_all_tests() { info!("Finished unit tests"); } -#[allow(dead_code)] -#[cfg(feature = "rt-tokio")] -pub fn block_on, T>(f: F) -> T { - let rt = tokio::runtime::Runtime::new().unwrap(); - rt.block_on(f) -} - -#[cfg(feature = "rt-async-std")] -#[allow(dead_code)] -pub fn block_on, T>(f: F) -> T { - async_std::task::block_on(f) +cfg_if::cfg_if! { + if #[cfg(feature = "rt-async-std")] { + #[allow(dead_code)] + pub fn block_on, T>(f: F) -> T { + async_std::task::block_on(f) + } + } else if #[cfg(feature = "rt-tokio")] { + #[allow(dead_code)] + pub fn block_on, T>(f: F) -> T { + let rt = tokio::runtime::Runtime::new().unwrap(); + rt.block_on(f) + } + } else { + compile_error!("needs executor implementation") + } } /////////////////////////////////////////////////////////////////////////// diff --git a/veilid-core/src/veilid_api/api.rs b/veilid-core/src/veilid_api/api.rs index 6c943e61..0b910a98 100644 --- a/veilid-core/src/veilid_api/api.rs +++ b/veilid-core/src/veilid_api/api.rs @@ -20,6 +20,19 @@ impl Drop for VeilidAPIInner { } } +/// The primary developer entrypoint into `veilid-core` functionality +/// +/// From [VeilidAPI] one can access: +/// +/// * [VeilidConfig] - The Veilid configuration specified by at startup time +/// * [Crypto] - The available set of cryptosystems provided by Veilid +/// * [TableStore] - The Veilid table-based encrypted persistent key-value store +/// * [ProtectedStore] - The Veilid abstract of the device's low-level 'protected secret storage' +/// * [VeilidState] - The current state of the Veilid node this API accesses +/// * [RoutingContext] - Communication methods between Veilid nodes and private routes +/// * Attach and detach from the network +/// * Create and import private routes +/// * Reply to `AppCall` RPCs #[derive(Clone, Debug)] pub struct VeilidAPI { inner: Arc>, @@ -48,7 +61,8 @@ impl VeilidAPI { } //////////////////////////////////////////////////////////////// - // Accessors + // Public Accessors + pub fn config(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { @@ -70,14 +84,6 @@ impl VeilidAPI { } Err(VeilidAPIError::not_initialized()) } - #[cfg(feature = "unstable-blockstore")] - pub fn block_store(&self) -> VeilidAPIResult { - let inner = self.inner.lock(); - if let Some(context) = &inner.context { - return Ok(context.block_store.clone()); - } - Err(VeilidAPIError::not_initialized()) - } pub fn protected_store(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { @@ -85,41 +91,52 @@ impl VeilidAPI { } Err(VeilidAPIError::not_initialized()) } - pub fn attachment_manager(&self) -> VeilidAPIResult { + + //////////////////////////////////////////////////////////////// + // Internal Accessors + pub(crate) fn attachment_manager(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { return Ok(context.attachment_manager.clone()); } Err(VeilidAPIError::not_initialized()) } - pub fn network_manager(&self) -> VeilidAPIResult { + pub(crate) fn network_manager(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { return Ok(context.attachment_manager.network_manager()); } Err(VeilidAPIError::not_initialized()) } - pub fn rpc_processor(&self) -> VeilidAPIResult { + pub(crate) fn rpc_processor(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { return Ok(context.attachment_manager.network_manager().rpc_processor()); } Err(VeilidAPIError::NotInitialized) } - pub fn routing_table(&self) -> VeilidAPIResult { + pub(crate) fn routing_table(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { return Ok(context.attachment_manager.network_manager().routing_table()); } Err(VeilidAPIError::NotInitialized) } - pub fn storage_manager(&self) -> VeilidAPIResult { + pub(crate) fn storage_manager(&self) -> VeilidAPIResult { let inner = self.inner.lock(); if let Some(context) = &inner.context { return Ok(context.storage_manager.clone()); } Err(VeilidAPIError::NotInitialized) } + #[cfg(feature = "unstable-blockstore")] + pub(crate) fn block_store(&self) -> VeilidAPIResult { + let inner = self.inner.lock(); + if let Some(context) = &inner.context { + return Ok(context.block_store.clone()); + } + Err(VeilidAPIError::not_initialized()) + } //////////////////////////////////////////////////////////////// // Attach/Detach @@ -162,10 +179,38 @@ impl VeilidAPI { //////////////////////////////////////////////////////////////// // Routing Context + /// Get a new `RoutingContext` object to use to send messages over the Veilid network. pub fn routing_context(&self) -> RoutingContext { RoutingContext::new(self.clone()) } + /// Parse a string into a target object that can be used in a [RoutingContext] + /// + /// Strings are in base64url format and can either be a remote route id or a node id. + /// Strings may have a [CryptoKind] [FourCC] prefix separated by a colon, such as: + /// `VLD0:XmnGyJrjMJBRC5ayJZRPXWTBspdX36-pbLb98H3UMeE` but if the prefix is left off + /// `XmnGyJrjMJBRC5ayJZRPXWTBspdX36-pbLb98H3UMeE` will be parsed with the 'best' cryptosystem + /// available (at the time of this writing this is `VLD0`) + pub async fn parse_as_target>(&self, s: S) -> VeilidAPIResult { + // Is this a route id? + if let Ok(rrid) = RouteId::from_str(s.as_ref()) { + let routing_table = self.routing_table()?; + let rss = routing_table.route_spec_store(); + + // Is this a valid remote route id? (can't target allocated routes) + if rss.is_route_id_remote(&rrid) { + return Ok(Target::PrivateRoute(rrid)); + } + } + + // Is this a node id? + if let Ok(nid) = TypedKey::from_str(s.as_ref()) { + return Ok(Target::NodeId(nid)); + } + + Err(VeilidAPIError::invalid_target()) + } + //////////////////////////////////////////////////////////////// // Private route allocation diff --git a/veilid-core/src/veilid_api/mod.rs b/veilid-core/src/veilid_api/mod.rs index 9c8e4e2d..67bea676 100644 --- a/veilid-core/src/veilid_api/mod.rs +++ b/veilid-core/src/veilid_api/mod.rs @@ -8,6 +8,7 @@ mod serialize_helpers; mod types; pub mod json_api; +#[doc(hidden)] pub mod tests; pub use api::*; @@ -18,19 +19,19 @@ pub use serialize_helpers::*; pub use types::*; pub use alloc::string::ToString; -pub use attachment_manager::AttachmentManager; pub use core::str::FromStr; pub use crypto::*; #[cfg(feature = "unstable-blockstore")] pub use intf::BlockStore; pub use intf::ProtectedStore; -pub use network_manager::NetworkManager; pub use routing_table::{NodeRef, NodeRefBase}; pub use table_store::{TableDB, TableDBTransaction, TableStore}; use crate::*; +use attachment_manager::AttachmentManager; use core::fmt; use core_context::{api_shutdown, VeilidCoreContext}; +use network_manager::NetworkManager; use routing_table::{Direction, RouteSpecStore, RoutingTable}; use rpc_processor::*; use storage_manager::StorageManager; diff --git a/veilid-core/src/veilid_api/tests/mod.rs b/veilid-core/src/veilid_api/tests/mod.rs index 9a4b8807..1d0d9680 100644 --- a/veilid-core/src/veilid_api/tests/mod.rs +++ b/veilid-core/src/veilid_api/tests/mod.rs @@ -1,4 +1,5 @@ mod fixtures; +#[doc(hidden)] pub mod test_serialize_json; mod test_types; mod test_types_dht; diff --git a/veilid-flutter/rust/src/dart_ffi.rs b/veilid-flutter/rust/src/dart_ffi.rs index 452944f3..319d4e02 100644 --- a/veilid-flutter/rust/src/dart_ffi.rs +++ b/veilid-flutter/rust/src/dart_ffi.rs @@ -1,5 +1,5 @@ +use veilid_core::tools::*; use crate::dart_isolate_wrapper::*; -use crate::tools::*; use allo_isolate::*; use cfg_if::*; use data_encoding::BASE64URL_NOPAD; @@ -10,13 +10,10 @@ use opentelemetry::*; use opentelemetry_otlp::WithExportConfig; use parking_lot::Mutex; use serde::*; -use std::str::FromStr; -use std::collections::BTreeMap; use std::os::raw::c_char; use std::sync::Arc; use tracing::*; use tracing_subscriber::prelude::*; -use tracing_subscriber::*; use veilid_core::Encodable as _; // Globals @@ -58,29 +55,6 @@ define_string_destructor!(free_string); type APIResult = veilid_core::VeilidAPIResult; const APIRESULT_VOID: APIResult<()> = APIResult::Ok(()); -// Parse target -async fn parse_target(s: String) -> APIResult { - - // Is this a route id? - if let Ok(rrid) = veilid_core::RouteId::from_str(&s) { - let veilid_api = get_veilid_api().await?; - let routing_table = veilid_api.routing_table()?; - let rss = routing_table.route_spec_store(); - - // Is this a valid remote route id? (can't target allocated routes) - if rss.is_route_id_remote(&rrid) { - return Ok(veilid_core::Target::PrivateRoute(rrid)); - } - } - - // Is this a node id? - if let Ok(nid) = veilid_core::TypedKey::from_str(&s) { - return Ok(veilid_core::Target::NodeId(nid)); - } - - Err(veilid_core::VeilidAPIError::invalid_target()) -} - ///////////////////////////////////////// // FFI-specific @@ -186,7 +160,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) { .expect("failed to deserialize plaform config json"); // Set up subscriber and layers - let subscriber = Registry::default(); + let subscriber = tracing_subscriber::Registry::default(); let mut layers = Vec::new(); let mut filters = (*FILTERS).lock(); @@ -194,7 +168,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) { if platform_config.logging.terminal.enabled { let filter = veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None); - let layer = fmt::Layer::new() + let layer = tracing_subscriber::fmt::Layer::new() .compact() .with_writer(std::io::stdout) .with_filter(filter.clone()); @@ -217,6 +191,8 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) { .tonic() .with_endpoint(format!("http://{}", grpc_endpoint)); let batch = opentelemetry::runtime::Tokio; + } else { + compile_error!("needs executor implementation") } } @@ -458,8 +434,8 @@ pub extern "C" fn routing_context_app_call(port: i64, id: u32, target: FfiStr, r }; routing_context.clone() }; - - let target = parse_target(target_string).await?; + let veilid_api = get_veilid_api().await?; + let target = veilid_api.parse_as_target(target_string).await?; let answer = routing_context.app_call(target, request).await?; let answer = data_encoding::BASE64URL_NOPAD.encode(&answer); APIResult::Ok(answer) @@ -485,7 +461,8 @@ pub extern "C" fn routing_context_app_message(port: i64, id: u32, target: FfiStr routing_context.clone() }; - let target = parse_target(target_string).await?; + let veilid_api = get_veilid_api().await?; + let target = veilid_api.parse_as_target(target_string).await?; routing_context.app_message(target, message).await?; APIRESULT_VOID }); diff --git a/veilid-flutter/rust/src/tools.rs b/veilid-flutter/rust/src/tools.rs index a42f10d0..fe17f75c 100644 --- a/veilid-flutter/rust/src/tools.rs +++ b/veilid-flutter/rust/src/tools.rs @@ -28,6 +28,7 @@ cfg_if! { lazy_static::lazy_static! { static ref GLOBAL_RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap(); } - + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-server/src/client_api.rs b/veilid-server/src/client_api.rs index d4ea2541..970b137c 100644 --- a/veilid-server/src/client_api.rs +++ b/veilid-server/src/client_api.rs @@ -22,6 +22,8 @@ cfg_if! { } else if #[cfg(feature="rt-tokio")] { use tokio::io::AsyncBufReadExt; use tokio::io::AsyncWriteExt; + } else { + compile_error!("needs executor implementation") } } @@ -114,7 +116,7 @@ impl ClientApi { cfg_if! { if #[cfg(feature="rt-async-std")] { let mut incoming_stream = listener.incoming(); - } else if #[cfg(feature="rt-tokio")] { + } else { let mut incoming_stream = tokio_stream::wrappers::TcpListenerStream::new(listener); } } @@ -318,7 +320,7 @@ impl ClientApi { use futures_util::AsyncReadExt; let (reader, mut writer) = stream.split(); let reader = BufReader::new(reader); - } else if #[cfg(feature="rt-tokio")] { + } else { let (reader, writer) = stream.into_split(); let reader = BufReader::new(reader); } diff --git a/veilid-server/src/tools.rs b/veilid-server/src/tools.rs index 65f296d5..c36322e1 100644 --- a/veilid-server/src/tools.rs +++ b/veilid-server/src/tools.rs @@ -48,6 +48,7 @@ cfg_if! { let local = tokio::task::LocalSet::new(); local.block_on(&rt, f) } - + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-server/src/veilid_logs.rs b/veilid-server/src/veilid_logs.rs index 494fda13..7f390f4f 100644 --- a/veilid-server/src/veilid_logs.rs +++ b/veilid-server/src/veilid_logs.rs @@ -80,6 +80,8 @@ impl VeilidLogs { .tonic() .with_endpoint(format!("http://{}", grpc_endpoint)); let batch = opentelemetry::runtime::Tokio; + } else { + compile_error!("needs executor implementation") } } diff --git a/veilid-tools/src/lib.rs b/veilid-tools/src/lib.rs index bbc422f1..b23c1001 100644 --- a/veilid-tools/src/lib.rs +++ b/veilid-tools/src/lib.rs @@ -127,7 +127,7 @@ cfg_if! { #[doc(no_inline)] pub use tokio::task::JoinHandle as LowLevelJoinHandle; } else { - #[compile_error("must use an executor")] + compile_error!("needs executor implementation") } } } diff --git a/veilid-wasm/Cargo.toml b/veilid-wasm/Cargo.toml index 685ef8d4..007ff7aa 100644 --- a/veilid-wasm/Cargo.toml +++ b/veilid-wasm/Cargo.toml @@ -9,11 +9,11 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [features] -default = [ "veilid-core/rt-wasm-bindgen", "veilid-core/default" ] -crypto-test = [ "veilid-core/rt-wasm-bindgen", "veilid-core/crypto-test"] +default = ["veilid-core/default"] +crypto-test = ["veilid-core/crypto-test"] [dependencies] -veilid-core = { path = "../veilid-core", default-features = false } +veilid-core = { path = "../veilid-core", default-features = false } tracing = { version = "^0", features = ["log", "attributes"] } tracing-wasm = "^0"