mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-01-25 22:15:59 -05:00
wasm cleanup
This commit is contained in:
parent
99bc2aaa5f
commit
91e1acb1d6
@ -149,7 +149,7 @@ sanitize-filename = "0.5.0"
|
|||||||
|
|
||||||
# Dependencies for native builds only
|
# Dependencies for native builds only
|
||||||
# Linux, Windows, Mac, iOS, Android
|
# Linux, Windows, Mac, iOS, Android
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
config = { version = "0.13.4", default-features = false, features = ["yaml"] }
|
config = { version = "0.13.4", default-features = false, features = ["yaml"] }
|
||||||
@ -186,7 +186,7 @@ rustls = "0.21.12"
|
|||||||
rustls-pemfile = "1.0.4"
|
rustls-pemfile = "1.0.4"
|
||||||
|
|
||||||
# Dependencies for WASM builds only
|
# Dependencies for WASM builds only
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
|
||||||
|
|
||||||
veilid-tools = { version = "0.4.1", path = "../veilid-tools", default-features = false, features = [
|
veilid-tools = { version = "0.4.1", path = "../veilid-tools", default-features = false, features = [
|
||||||
"rt-wasm-bindgen",
|
"rt-wasm-bindgen",
|
||||||
@ -221,7 +221,7 @@ tracing-wasm = "0.2.1"
|
|||||||
keyvaluedb-web = "0.1.2"
|
keyvaluedb-web = "0.1.2"
|
||||||
|
|
||||||
### Configuration for WASM32 'web-sys' crate
|
### Configuration for WASM32 'web-sys' crate
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies.web-sys]
|
||||||
version = "0.3.69"
|
version = "0.3.69"
|
||||||
features = [
|
features = [
|
||||||
'Document',
|
'Document',
|
||||||
@ -259,12 +259,12 @@ tracing-oslog = { version = "0.1.2", optional = true }
|
|||||||
|
|
||||||
### DEV DEPENDENCIES
|
### DEV DEPENDENCIES
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies]
|
||||||
simplelog = { version = "0.12.2", features = ["test"] }
|
simplelog = { version = "0.12.2", features = ["test"] }
|
||||||
serial_test = "2.0.0"
|
serial_test = "2.0.0"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
|
||||||
serial_test = { version = "2.0.0", default-features = false, features = [
|
serial_test = { version = "2.0.0", default-features = false, features = [
|
||||||
"async",
|
"async",
|
||||||
] }
|
] }
|
||||||
|
@ -78,7 +78,7 @@ where
|
|||||||
macro_rules! byte_array_type {
|
macro_rules! byte_array_type {
|
||||||
($name:ident, $size:expr, $encoded_size:expr) => {
|
($name:ident, $size:expr, $encoded_size:expr) => {
|
||||||
#[derive(Clone, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(into_wasm_abi))]
|
||||||
pub struct $name {
|
pub struct $name {
|
||||||
pub bytes: [u8; $size],
|
pub bytes: [u8; $size],
|
||||||
}
|
}
|
||||||
@ -280,17 +280,17 @@ macro_rules! byte_array_type {
|
|||||||
|
|
||||||
byte_array_type!(CryptoKey, CRYPTO_KEY_LENGTH, CRYPTO_KEY_LENGTH_ENCODED);
|
byte_array_type!(CryptoKey, CRYPTO_KEY_LENGTH, CRYPTO_KEY_LENGTH_ENCODED);
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type PublicKey = CryptoKey;
|
pub type PublicKey = CryptoKey;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type SecretKey = CryptoKey;
|
pub type SecretKey = CryptoKey;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type HashDigest = CryptoKey;
|
pub type HashDigest = CryptoKey;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type SharedSecret = CryptoKey;
|
pub type SharedSecret = CryptoKey;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type RouteId = CryptoKey;
|
pub type RouteId = CryptoKey;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type CryptoKeyDistance = CryptoKey;
|
pub type CryptoKeyDistance = CryptoKey;
|
||||||
|
|
||||||
byte_array_type!(Signature, SIGNATURE_LENGTH, SIGNATURE_LENGTH_ENCODED);
|
byte_array_type!(Signature, SIGNATURE_LENGTH, SIGNATURE_LENGTH_ENCODED);
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi)
|
tsify(from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
|
@ -6,7 +6,7 @@ use core::fmt;
|
|||||||
use core::hash::Hash;
|
use core::hash::Hash;
|
||||||
|
|
||||||
/// Cryptography version fourcc code
|
/// Cryptography version fourcc code
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type CryptoKind = FourCC;
|
pub type CryptoKind = FourCC;
|
||||||
|
|
||||||
/// Sort best crypto kinds first
|
/// Sort best crypto kinds first
|
||||||
@ -52,24 +52,24 @@ pub use crypto_typed::*;
|
|||||||
pub use crypto_typed_group::*;
|
pub use crypto_typed_group::*;
|
||||||
pub use keypair::*;
|
pub use keypair::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedKey = CryptoTyped<PublicKey>;
|
pub type TypedKey = CryptoTyped<PublicKey>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSecret = CryptoTyped<SecretKey>;
|
pub type TypedSecret = CryptoTyped<SecretKey>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedKeyPair = CryptoTyped<KeyPair>;
|
pub type TypedKeyPair = CryptoTyped<KeyPair>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSignature = CryptoTyped<Signature>;
|
pub type TypedSignature = CryptoTyped<Signature>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSharedSecret = CryptoTyped<SharedSecret>;
|
pub type TypedSharedSecret = CryptoTyped<SharedSecret>;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedKeyGroup = CryptoTypedGroup<PublicKey>;
|
pub type TypedKeyGroup = CryptoTypedGroup<PublicKey>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSecretGroup = CryptoTypedGroup<SecretKey>;
|
pub type TypedSecretGroup = CryptoTypedGroup<SecretKey>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedKeyPairGroup = CryptoTypedGroup<KeyPair>;
|
pub type TypedKeyPairGroup = CryptoTypedGroup<KeyPair>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSignatureGroup = CryptoTypedGroup<Signature>;
|
pub type TypedSignatureGroup = CryptoTypedGroup<Signature>;
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type TypedSharedSecretGroup = CryptoTypedGroup<SharedSecret>;
|
pub type TypedSharedSecretGroup = CryptoTypedGroup<SharedSecret>;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
mod wasm;
|
mod wasm;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
pub use wasm::*;
|
pub use wasm::*;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
mod native;
|
mod native;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
pub use native::*;
|
pub use native::*;
|
||||||
|
|
||||||
pub static KNOWN_PROTECTED_STORE_KEYS: [&str; 2] = ["device_encryption_key", "_test_key"];
|
pub static KNOWN_PROTECTED_STORE_KEYS: [&str; 2] = ["device_encryption_key", "_test_key"];
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
#[cfg(any(feature = "rt-async-std", feature = "rt-tokio"))]
|
#[cfg(any(feature = "rt-async-std", feature = "rt-tokio"))]
|
||||||
compile_error!("features \"rt-async-std\" and \"rt-tokio\" can not be specified for WASM");
|
compile_error!("features \"rt-async-std\" and \"rt-tokio\" can not be specified for WASM");
|
||||||
} else {
|
} else {
|
||||||
|
@ -574,7 +574,7 @@ impl ConnectionManager {
|
|||||||
|
|
||||||
// Called by low-level network when any connection-oriented protocol connection appears
|
// Called by low-level network when any connection-oriented protocol connection appears
|
||||||
// either from incoming connections.
|
// either from incoming connections.
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub(super) async fn on_accepted_protocol_network_connection(
|
pub(super) async fn on_accepted_protocol_network_connection(
|
||||||
&self,
|
&self,
|
||||||
protocol_connection: ProtocolNetworkConnection,
|
protocol_connection: ProtocolNetworkConnection,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
mod native;
|
mod native;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
mod wasm;
|
mod wasm;
|
||||||
|
|
||||||
mod address_check;
|
mod address_check;
|
||||||
@ -36,16 +36,16 @@ use connection_handle::*;
|
|||||||
use crypto::*;
|
use crypto::*;
|
||||||
use futures_util::stream::FuturesUnordered;
|
use futures_util::stream::FuturesUnordered;
|
||||||
use hashlink::LruCache;
|
use hashlink::LruCache;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
use native::*;
|
use native::*;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
pub use native::{MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES};
|
pub use native::{MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES};
|
||||||
use routing_table::*;
|
use routing_table::*;
|
||||||
use rpc_processor::*;
|
use rpc_processor::*;
|
||||||
use storage_manager::*;
|
use storage_manager::*;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
use wasm::*;
|
use wasm::*;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
pub use wasm::{/* LOCAL_NETWORK_CAPABILITIES, */ MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES,};
|
pub use wasm::{/* LOCAL_NETWORK_CAPABILITIES, */ MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES,};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -119,7 +119,7 @@ enum SendDataToExistingFlowResult {
|
|||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum StartupDisposition {
|
pub enum StartupDisposition {
|
||||||
Success,
|
Success,
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
BindRetry,
|
BindRetry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use std::{io, sync::Arc};
|
|||||||
use stop_token::prelude::*;
|
use stop_token::prelude::*;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
// No accept support for WASM
|
// No accept support for WASM
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ impl Address {
|
|||||||
SocketAddr::V6(v6) => Address::IPV6(*v6.ip()),
|
SocketAddr::V6(v6) => Address::IPV6(*v6.ip()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub fn from_ip_addr(addr: IpAddr) -> Address {
|
pub fn from_ip_addr(addr: IpAddr) -> Address {
|
||||||
match addr {
|
match addr {
|
||||||
IpAddr::V4(v4) => Address::IPV4(v4),
|
IpAddr::V4(v4) => Address::IPV4(v4),
|
||||||
|
@ -268,7 +268,7 @@ impl DialInfo {
|
|||||||
Self::WSS(di) => di.socket_address.port(),
|
Self::WSS(di) => di.socket_address.port(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub fn set_port(&mut self, port: u16) {
|
pub fn set_port(&mut self, port: u16) {
|
||||||
match self {
|
match self {
|
||||||
Self::UDP(di) => di.socket_address.set_port(port),
|
Self::UDP(di) => di.socket_address.set_port(port),
|
||||||
@ -366,7 +366,7 @@ impl DialInfo {
|
|||||||
// This will not be used on signed dialinfo, only for bootstrapping, so we don't need to worry about
|
// This will not be used on signed dialinfo, only for bootstrapping, so we don't need to worry about
|
||||||
// the '0.0.0.0' address being propagated across the routing table
|
// the '0.0.0.0' address being propagated across the routing table
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
vec![SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0,0,0,0)), port)]
|
vec![SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0,0,0,0)), port)]
|
||||||
} else {
|
} else {
|
||||||
match split_url.host {
|
match split_url.host {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[build]
|
[build]
|
||||||
target = "wasm32-unknown-unknown"
|
all(target_arch = "wasm32", target_os = "unknown")
|
||||||
|
@ -9,29 +9,6 @@ struct WebsocketNetworkConnectionInner {
|
|||||||
ws_stream: CloneStream<WsStream>,
|
ws_stream: CloneStream<WsStream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_io(err: WsErr) -> io::Error {
|
|
||||||
match err {
|
|
||||||
WsErr::InvalidWsState { supplied: _ } => {
|
|
||||||
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
|
||||||
}
|
|
||||||
WsErr::ConnectionNotOpen => io::Error::new(io::ErrorKind::NotConnected, err.to_string()),
|
|
||||||
WsErr::InvalidUrl { supplied: _ } => {
|
|
||||||
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
|
||||||
}
|
|
||||||
WsErr::InvalidCloseCode { supplied: _ } => {
|
|
||||||
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
|
||||||
}
|
|
||||||
WsErr::ReasonStringToLong => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
|
||||||
WsErr::ConnectionFailed { event: _ } => {
|
|
||||||
io::Error::new(io::ErrorKind::ConnectionRefused, err.to_string())
|
|
||||||
}
|
|
||||||
WsErr::InvalidEncoding => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
|
||||||
WsErr::CantDecodeBlob => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
|
||||||
WsErr::UnknownDataType => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
|
||||||
_ => io::Error::new(io::ErrorKind::Other, err.to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WebsocketNetworkConnection {
|
pub struct WebsocketNetworkConnection {
|
||||||
flow: Flow,
|
flow: Flow,
|
||||||
@ -65,7 +42,7 @@ impl WebsocketNetworkConnection {
|
|||||||
)]
|
)]
|
||||||
pub async fn close(&self) -> io::Result<NetworkResult<()>> {
|
pub async fn close(&self) -> io::Result<NetworkResult<()>> {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
let x = self.inner.ws_meta.close().await.map_err(to_io);
|
let x = self.inner.ws_meta.close().await.map_err(ws_err_to_io_error);
|
||||||
#[cfg(feature = "verbose-tracing")]
|
#[cfg(feature = "verbose-tracing")]
|
||||||
log_net!(debug "close result: {:?}", x);
|
log_net!(debug "close result: {:?}", x);
|
||||||
Ok(NetworkResult::value(()))
|
Ok(NetworkResult::value(()))
|
||||||
@ -83,7 +60,7 @@ impl WebsocketNetworkConnection {
|
|||||||
.send(WsMessage::Binary(message)),
|
.send(WsMessage::Binary(message)),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(to_io)
|
.map_err(ws_err_to_io_error)
|
||||||
.into_network_result()?;
|
.into_network_result()?;
|
||||||
|
|
||||||
#[cfg(feature = "verbose-tracing")]
|
#[cfg(feature = "verbose-tracing")]
|
||||||
@ -140,7 +117,9 @@ impl WebsocketProtocolHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let fut = SendWrapper::new(timeout(timeout_ms, async move {
|
let fut = SendWrapper::new(timeout(timeout_ms, async move {
|
||||||
WsMeta::connect(request, None).await.map_err(to_io)
|
WsMeta::connect(request, None)
|
||||||
|
.await
|
||||||
|
.map_err(ws_err_to_io_error)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let (wsmeta, wsio) = network_result_try!(network_result_try!(fut
|
let (wsmeta, wsio) = network_result_try!(network_result_try!(fut
|
||||||
|
@ -612,7 +612,7 @@ impl RoutingTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the domain's currently registered network class
|
/// Return the domain's currently registered network class
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub fn get_network_class(&self, routing_domain: RoutingDomain) -> Option<NetworkClass> {
|
pub fn get_network_class(&self, routing_domain: RoutingDomain) -> Option<NetworkClass> {
|
||||||
self.inner.read().get_network_class(routing_domain)
|
self.inner.read().get_network_class(routing_domain)
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ impl RoutingTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Makes a filter that finds nodes with a matching inbound dialinfo
|
/// Makes a filter that finds nodes with a matching inbound dialinfo
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub fn make_inbound_dial_info_entry_filter<'a>(
|
pub fn make_inbound_dial_info_entry_filter<'a>(
|
||||||
routing_domain: RoutingDomain,
|
routing_domain: RoutingDomain,
|
||||||
dial_info_filter: DialInfoFilter,
|
dial_info_filter: DialInfoFilter,
|
||||||
|
@ -7,7 +7,7 @@ pub trait RoutingDomainEditorCommonTrait {
|
|||||||
protocol_type: Option<ProtocolType>,
|
protocol_type: Option<ProtocolType>,
|
||||||
) -> &mut Self;
|
) -> &mut Self;
|
||||||
fn set_relay_node(&mut self, relay_node: Option<NodeRef>) -> &mut Self;
|
fn set_relay_node(&mut self, relay_node: Option<NodeRef>) -> &mut Self;
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
fn add_dial_info(&mut self, dial_info: DialInfo, class: DialInfoClass) -> &mut Self;
|
fn add_dial_info(&mut self, dial_info: DialInfo, class: DialInfoClass) -> &mut Self;
|
||||||
fn setup_network(
|
fn setup_network(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -83,7 +83,7 @@ pub(super) enum RoutingDomainChangeCommon {
|
|||||||
AddDialInfo {
|
AddDialInfo {
|
||||||
dial_info_detail: DialInfoDetail,
|
dial_info_detail: DialInfoDetail,
|
||||||
},
|
},
|
||||||
// #[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
// #[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
// RemoveDialInfoDetail {
|
// RemoveDialInfoDetail {
|
||||||
// dial_info_detail: DialInfoDetail,
|
// dial_info_detail: DialInfoDetail,
|
||||||
// },
|
// },
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#![cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ impl RoutingDomainDetailCommon {
|
|||||||
|
|
||||||
pub fn network_class(&self) -> Option<NetworkClass> {
|
pub fn network_class(&self) -> Option<NetworkClass> {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
Some(NetworkClass::WebApp)
|
Some(NetworkClass::WebApp)
|
||||||
} else {
|
} else {
|
||||||
if self.address_types.is_empty() {
|
if self.address_types.is_empty() {
|
||||||
|
@ -52,7 +52,7 @@ impl RPCError {
|
|||||||
pub fn map_network<M: ToString, X: ToString>(message: M) -> impl FnOnce(X) -> Self {
|
pub fn map_network<M: ToString, X: ToString>(message: M) -> impl FnOnce(X) -> Self {
|
||||||
move |x| Self::Network(format!("{}: {}", message.to_string(), x.to_string()))
|
move |x| Self::Network(format!("{}: {}", message.to_string(), x.to_string()))
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", expect(dead_code))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), expect(dead_code))]
|
||||||
pub fn try_again<X: ToString>(x: X) -> Self {
|
pub fn try_again<X: ToString>(x: X) -> Self {
|
||||||
Self::TryAgain(x.to_string())
|
Self::TryAgain(x.to_string())
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ pub use table_db::*;
|
|||||||
|
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
mod wasm;
|
mod wasm;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
use wasm::*;
|
use wasm::*;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
mod native;
|
mod native;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
use native::*;
|
use native::*;
|
||||||
|
|
||||||
use keyvaluedb::*;
|
use keyvaluedb::*;
|
||||||
@ -20,14 +20,14 @@ const ALL_TABLE_NAMES: &[u8] = b"all_table_names";
|
|||||||
|
|
||||||
/// Description of column
|
/// Description of column
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct ColumnInfo {
|
pub struct ColumnInfo {
|
||||||
pub key_count: AlignedU64,
|
pub key_count: AlignedU64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// IO Stats for table
|
/// IO Stats for table
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct IOStatsInfo {
|
pub struct IOStatsInfo {
|
||||||
/// Number of transaction.
|
/// Number of transaction.
|
||||||
pub transactions: AlignedU64,
|
pub transactions: AlignedU64,
|
||||||
@ -51,7 +51,7 @@ pub struct IOStatsInfo {
|
|||||||
|
|
||||||
/// Description of table
|
/// Description of table
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct TableInfo {
|
pub struct TableInfo {
|
||||||
/// Internal table name
|
/// Internal table name
|
||||||
pub table_name: String,
|
pub table_name: String,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use keyvaluedb_web::*;
|
use keyvaluedb_web::*;
|
||||||
use keyvaluedb::*;
|
use keyvaluedb::*;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(target_arch = "wasm32"))] {
|
if #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@ -61,7 +61,7 @@ wFAbkZY9eS/x6P7qrpd7dUA=
|
|||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
|
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
pub fn get_table_store_path() -> String {
|
pub fn get_table_store_path() -> String {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
@ -207,9 +207,9 @@ pub fn config_callback(key: String) -> ConfigCallbackReturn {
|
|||||||
"network.routing_table.node_id" => Ok(Box::new(TypedKeyGroup::new())),
|
"network.routing_table.node_id" => Ok(Box::new(TypedKeyGroup::new())),
|
||||||
"network.routing_table.node_id_secret" => Ok(Box::new(TypedSecretGroup::new())),
|
"network.routing_table.node_id_secret" => Ok(Box::new(TypedSecretGroup::new())),
|
||||||
// "network.routing_table.bootstrap" => Ok(Box::new(Vec::<String>::new())),
|
// "network.routing_table.bootstrap" => Ok(Box::new(Vec::<String>::new())),
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
"network.routing_table.bootstrap" => Ok(Box::new(vec!["bootstrap.veilid.net".to_string()])),
|
"network.routing_table.bootstrap" => Ok(Box::new(vec!["bootstrap.veilid.net".to_string()])),
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
"network.routing_table.bootstrap" => Ok(Box::new(vec![
|
"network.routing_table.bootstrap" => Ok(Box::new(vec![
|
||||||
"ws://bootstrap.veilid.net:5150/ws".to_string(),
|
"ws://bootstrap.veilid.net:5150/ws".to_string(),
|
||||||
])),
|
])),
|
||||||
@ -349,12 +349,12 @@ pub async fn test_config() {
|
|||||||
assert_eq!(inner.network.rpc.default_route_hop_count, 1u8);
|
assert_eq!(inner.network.rpc.default_route_hop_count, 1u8);
|
||||||
assert_eq!(inner.network.routing_table.node_id.len(), 0);
|
assert_eq!(inner.network.routing_table.node_id.len(), 0);
|
||||||
assert_eq!(inner.network.routing_table.node_id_secret.len(), 0);
|
assert_eq!(inner.network.routing_table.node_id_secret.len(), 0);
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
inner.network.routing_table.bootstrap,
|
inner.network.routing_table.bootstrap,
|
||||||
vec!["bootstrap.veilid.net"],
|
vec!["bootstrap.veilid.net"],
|
||||||
);
|
);
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
inner.network.routing_table.bootstrap,
|
inner.network.routing_table.bootstrap,
|
||||||
vec!["ws://bootstrap.veilid.net:5150/ws"],
|
vec!["ws://bootstrap.veilid.net:5150/ws"],
|
||||||
|
@ -3,7 +3,7 @@ mod android;
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
#[cfg(all(target_os = "ios", feature = "veilid_core_ios_tests"))]
|
#[cfg(all(target_os = "ios", feature = "veilid_core_ios_tests"))]
|
||||||
mod ios;
|
mod ios;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
mod native;
|
mod native;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Test suite for Native
|
//! Test suite for Native
|
||||||
#![cfg(not(target_arch = "wasm32"))]
|
#![cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ macro_rules! apibail_already_initialized {
|
|||||||
#[derive(
|
#[derive(
|
||||||
ThisError, Clone, Debug, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema,
|
ThisError, Clone, Debug, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(into_wasm_abi))]
|
||||||
#[serde(tag = "kind")]
|
#[serde(tag = "kind")]
|
||||||
pub enum VeilidAPIError {
|
pub enum VeilidAPIError {
|
||||||
#[error("Not initialized")]
|
#[error("Not initialized")]
|
||||||
|
@ -21,13 +21,13 @@ macro_rules! aligned_u64_type {
|
|||||||
Deserialize,
|
Deserialize,
|
||||||
JsonSchema,
|
JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
#[repr(C, align(8))]
|
#[repr(C, align(8))]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct $name(
|
pub struct $name(
|
||||||
#[serde(with = "as_human_string")]
|
#[serde(with = "as_human_string")]
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(type = "string"))]
|
||||||
u64,
|
u64,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,22 +2,22 @@ use super::*;
|
|||||||
|
|
||||||
/// Direct statement blob passed to hosting application for processing.
|
/// Direct statement blob passed to hosting application for processing.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidAppMessage {
|
pub struct VeilidAppMessage {
|
||||||
#[serde(with = "as_human_opt_string")]
|
#[serde(with = "as_human_opt_string")]
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional, type = "string"))]
|
||||||
sender: Option<TypedKey>,
|
sender: Option<TypedKey>,
|
||||||
|
|
||||||
#[serde(with = "as_human_opt_string")]
|
#[serde(with = "as_human_opt_string")]
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional, type = "string"))]
|
||||||
route_id: Option<RouteId>,
|
route_id: Option<RouteId>,
|
||||||
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
|
#[cfg_attr(not(all(target_arch = "wasm32", target_os = "unknown")), serde(with = "as_human_base64"))]
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
serde(with = "serde_bytes"),
|
serde(with = "serde_bytes"),
|
||||||
tsify(type = "Uint8Array")
|
tsify(type = "Uint8Array")
|
||||||
)]
|
)]
|
||||||
@ -51,22 +51,22 @@ impl VeilidAppMessage {
|
|||||||
|
|
||||||
/// Direct question blob passed to hosting application for processing to send an eventual AppReply.
|
/// Direct question blob passed to hosting application for processing to send an eventual AppReply.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidAppCall {
|
pub struct VeilidAppCall {
|
||||||
#[serde(with = "as_human_opt_string")]
|
#[serde(with = "as_human_opt_string")]
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
sender: Option<TypedKey>,
|
sender: Option<TypedKey>,
|
||||||
|
|
||||||
#[serde(with = "as_human_opt_string")]
|
#[serde(with = "as_human_opt_string")]
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional, type = "string"))]
|
||||||
route_id: Option<RouteId>,
|
route_id: Option<RouteId>,
|
||||||
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
|
#[cfg_attr(not(all(target_arch = "wasm32", target_os = "unknown")), serde(with = "as_human_base64"))]
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
serde(with = "serde_bytes"),
|
serde(with = "serde_bytes"),
|
||||||
tsify(type = "Uint8Array")
|
tsify(type = "Uint8Array")
|
||||||
)]
|
)]
|
||||||
|
@ -3,7 +3,7 @@ use super::*;
|
|||||||
/// DHT Record Descriptor
|
/// DHT Record Descriptor
|
||||||
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi)
|
tsify(from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
@ -17,7 +17,7 @@ pub struct DHTRecordDescriptor {
|
|||||||
/// If this key is being created: Some(the secret key of the owner)
|
/// If this key is being created: Some(the secret key of the owner)
|
||||||
/// If this key is just being opened: None
|
/// If this key is just being opened: None
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
owner_secret: Option<SecretKey>,
|
owner_secret: Option<SecretKey>,
|
||||||
/// The schema in use associated with the key
|
/// The schema in use associated with the key
|
||||||
schema: DHTSchema,
|
schema: DHTSchema,
|
||||||
|
@ -3,7 +3,7 @@ use super::*;
|
|||||||
/// DHT Record Report
|
/// DHT Record Report
|
||||||
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi)
|
tsify(from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
@ -67,7 +67,7 @@ impl fmt::Debug for DHTRecordReport {
|
|||||||
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
||||||
)]
|
)]
|
||||||
|
@ -13,10 +13,10 @@ pub use value_data::*;
|
|||||||
pub use value_subkey_range_set::*;
|
pub use value_subkey_range_set::*;
|
||||||
|
|
||||||
/// Value subkey
|
/// Value subkey
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type ValueSubkey = u32;
|
pub type ValueSubkey = u32;
|
||||||
/// Value sequence number
|
/// Value sequence number
|
||||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), declare)]
|
||||||
pub type ValueSeqNum = u32;
|
pub type ValueSeqNum = u32;
|
||||||
|
|
||||||
pub(crate) fn debug_seqs(seqs: &[ValueSeqNum]) -> String {
|
pub(crate) fn debug_seqs(seqs: &[ValueSeqNum]) -> String {
|
||||||
|
@ -3,7 +3,7 @@ use crate::storage_manager::{MAX_RECORD_DATA_SIZE, MAX_SUBKEY_SIZE};
|
|||||||
|
|
||||||
/// Default DHT Schema (DFLT)
|
/// Default DHT Schema (DFLT)
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(from_wasm_abi))]
|
||||||
pub struct DHTSchemaDFLT {
|
pub struct DHTSchemaDFLT {
|
||||||
/// Owner subkey count
|
/// Owner subkey count
|
||||||
o_cnt: u16,
|
o_cnt: u16,
|
||||||
|
@ -9,7 +9,11 @@ pub use smpl::*;
|
|||||||
/// Enum over all the supported DHT Schemas
|
/// Enum over all the supported DHT Schemas
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
||||||
#[serde(tag = "kind")]
|
#[serde(tag = "kind")]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
|
derive(Tsify),
|
||||||
|
tsify(from_wasm_abi)
|
||||||
|
)]
|
||||||
pub enum DHTSchema {
|
pub enum DHTSchema {
|
||||||
DFLT(DHTSchemaDFLT),
|
DFLT(DHTSchemaDFLT),
|
||||||
SMPL(DHTSchemaSMPL),
|
SMPL(DHTSchemaSMPL),
|
||||||
|
@ -3,7 +3,11 @@ use crate::storage_manager::{MAX_RECORD_DATA_SIZE, MAX_SUBKEY_SIZE};
|
|||||||
|
|
||||||
/// Simple DHT Schema (SMPL) Member
|
/// Simple DHT Schema (SMPL) Member
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
|
derive(Tsify),
|
||||||
|
tsify(from_wasm_abi)
|
||||||
|
)]
|
||||||
pub struct DHTSchemaSMPLMember {
|
pub struct DHTSchemaSMPLMember {
|
||||||
/// Member key
|
/// Member key
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
@ -14,7 +18,11 @@ pub struct DHTSchemaSMPLMember {
|
|||||||
|
|
||||||
/// Simple DHT Schema (SMPL)
|
/// Simple DHT Schema (SMPL)
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
|
derive(Tsify),
|
||||||
|
tsify(from_wasm_abi)
|
||||||
|
)]
|
||||||
pub struct DHTSchemaSMPL {
|
pub struct DHTSchemaSMPL {
|
||||||
/// Owner subkey count
|
/// Owner subkey count
|
||||||
o_cnt: u16,
|
o_cnt: u16,
|
||||||
|
@ -2,16 +2,16 @@ use super::*;
|
|||||||
use veilid_api::VeilidAPIResult;
|
use veilid_api::VeilidAPIResult;
|
||||||
|
|
||||||
#[derive(Clone, Default, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(into_wasm_abi))]
|
||||||
pub struct ValueData {
|
pub struct ValueData {
|
||||||
/// An increasing sequence number to time-order the DHT record changes
|
/// An increasing sequence number to time-order the DHT record changes
|
||||||
seq: ValueSeqNum,
|
seq: ValueSeqNum,
|
||||||
|
|
||||||
/// The contents of a DHT Record
|
/// The contents of a DHT Record
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
|
#[cfg_attr(not(all(target_arch = "wasm32", target_os = "unknown")), serde(with = "as_human_base64"))]
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
serde(with = "serde_bytes"),
|
serde(with = "serde_bytes"),
|
||||||
tsify(type = "Uint8Array")
|
tsify(type = "Uint8Array")
|
||||||
)]
|
)]
|
||||||
|
@ -6,7 +6,7 @@ use range_set_blaze::*;
|
|||||||
Clone, Default, Hash, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema,
|
Clone, Default, Hash, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi)
|
tsify(from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
|
@ -5,7 +5,7 @@ use super::*;
|
|||||||
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
||||||
)]
|
)]
|
||||||
@ -27,7 +27,7 @@ impl Default for Sequencing {
|
|||||||
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
||||||
)]
|
)]
|
||||||
@ -48,7 +48,7 @@ impl Default for Stability {
|
|||||||
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
tsify(from_wasm_abi, into_wasm_abi, namespace)
|
||||||
)]
|
)]
|
||||||
@ -79,11 +79,11 @@ impl Default for SafetySelection {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct SafetySpec {
|
pub struct SafetySpec {
|
||||||
/// Preferred safety route set id if it still exists.
|
/// Preferred safety route set id if it still exists.
|
||||||
#[schemars(with = "Option<String>")]
|
#[schemars(with = "Option<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional, type = "string"))]
|
||||||
pub preferred_route: Option<RouteId>,
|
pub preferred_route: Option<RouteId>,
|
||||||
/// Must be greater than 0.
|
/// Must be greater than 0.
|
||||||
pub hop_count: usize,
|
pub hop_count: usize,
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
|
|
||||||
/// Measurement of communications latency to this node over all RPC questions
|
/// Measurement of communications latency to this node over all RPC questions
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct LatencyStats {
|
pub struct LatencyStats {
|
||||||
/// fastest latency in the ROLLING_LATENCIES_SIZE last latencies
|
/// fastest latency in the ROLLING_LATENCIES_SIZE last latencies
|
||||||
pub fastest: TimestampDuration,
|
pub fastest: TimestampDuration,
|
||||||
@ -25,7 +25,7 @@ impl fmt::Display for LatencyStats {
|
|||||||
|
|
||||||
/// Measurement of how much data has transferred to or from this node over a time span
|
/// Measurement of how much data has transferred to or from this node over a time span
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct TransferStats {
|
pub struct TransferStats {
|
||||||
/// total amount transferred ever
|
/// total amount transferred ever
|
||||||
pub total: ByteCount,
|
pub total: ByteCount,
|
||||||
@ -50,7 +50,7 @@ impl fmt::Display for TransferStats {
|
|||||||
|
|
||||||
/// Transfer statistics from a node to our own (down) and
|
/// Transfer statistics from a node to our own (down) and
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct TransferStatsDownUp {
|
pub struct TransferStatsDownUp {
|
||||||
pub down: TransferStats,
|
pub down: TransferStats,
|
||||||
pub up: TransferStats,
|
pub up: TransferStats,
|
||||||
@ -66,7 +66,7 @@ impl fmt::Display for TransferStatsDownUp {
|
|||||||
|
|
||||||
/// Measurement of what states the node has been in over a time span
|
/// Measurement of what states the node has been in over a time span
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct StateStats {
|
pub struct StateStats {
|
||||||
/// total amount of time measured
|
/// total amount of time measured
|
||||||
pub span: TimestampDuration,
|
pub span: TimestampDuration,
|
||||||
@ -97,7 +97,7 @@ impl fmt::Display for StateStats {
|
|||||||
|
|
||||||
/// Measurement of what state reasons the node has been in over a time span
|
/// Measurement of what state reasons the node has been in over a time span
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct StateReasonStats {
|
pub struct StateReasonStats {
|
||||||
/// time spent dead due to being unable to send
|
/// time spent dead due to being unable to send
|
||||||
pub can_not_send: TimestampDuration,
|
pub can_not_send: TimestampDuration,
|
||||||
@ -139,7 +139,7 @@ impl fmt::Display for StateReasonStats {
|
|||||||
|
|
||||||
/// Measurement of round-trip RPC question/answer performance
|
/// Measurement of round-trip RPC question/answer performance
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct AnswerStats {
|
pub struct AnswerStats {
|
||||||
/// total amount of time measured
|
/// total amount of time measured
|
||||||
pub span: TimestampDuration,
|
pub span: TimestampDuration,
|
||||||
@ -192,7 +192,7 @@ impl fmt::Display for AnswerStats {
|
|||||||
|
|
||||||
/// Statistics for RPC operations performed on a node
|
/// Statistics for RPC operations performed on a node
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct RPCStats {
|
pub struct RPCStats {
|
||||||
/// number of rpcs that have been sent in the total entry time range
|
/// number of rpcs that have been sent in the total entry time range
|
||||||
pub messages_sent: u32,
|
pub messages_sent: u32,
|
||||||
@ -263,7 +263,7 @@ impl fmt::Display for RPCStats {
|
|||||||
|
|
||||||
/// Statistics for a peer in the routing table
|
/// Statistics for a peer in the routing table
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct PeerStats {
|
pub struct PeerStats {
|
||||||
/// when the peer was added to the routing table
|
/// when the peer was added to the routing table
|
||||||
pub time_added: Timestamp,
|
pub time_added: Timestamp,
|
||||||
|
@ -4,7 +4,7 @@ use super::*;
|
|||||||
#[derive(
|
#[derive(
|
||||||
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize, Deserialize, JsonSchema,
|
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize, Deserialize, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(namespace))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(namespace))]
|
||||||
pub enum VeilidLogLevel {
|
pub enum VeilidLogLevel {
|
||||||
Error = 1,
|
Error = 1,
|
||||||
Warn = 2,
|
Warn = 2,
|
||||||
@ -81,10 +81,10 @@ impl fmt::Display for VeilidLogLevel {
|
|||||||
}
|
}
|
||||||
/// A VeilidCore log message with optional backtrace.
|
/// A VeilidCore log message with optional backtrace.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidLog {
|
pub struct VeilidLog {
|
||||||
pub log_level: VeilidLogLevel,
|
pub log_level: VeilidLogLevel,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub backtrace: Option<String>,
|
pub backtrace: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use super::*;
|
|||||||
/// Attachment abstraction for network 'signal strength'.
|
/// Attachment abstraction for network 'signal strength'.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(namespace, from_wasm_abi, into_wasm_abi)
|
tsify(namespace, from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
@ -77,7 +77,7 @@ impl TryFrom<&str> for AttachmentState {
|
|||||||
|
|
||||||
/// Describe the attachment state of the Veilid node
|
/// Describe the attachment state of the Veilid node
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidStateAttachment {
|
pub struct VeilidStateAttachment {
|
||||||
/// The overall quality of the routing table if attached, or the current state the attachment state machine.
|
/// The overall quality of the routing table if attached, or the current state the attachment state machine.
|
||||||
pub state: AttachmentState,
|
pub state: AttachmentState,
|
||||||
@ -94,11 +94,11 @@ pub struct VeilidStateAttachment {
|
|||||||
|
|
||||||
/// Describe a recently accessed peer
|
/// Describe a recently accessed peer
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct PeerTableData {
|
pub struct PeerTableData {
|
||||||
/// The node ids used by this peer
|
/// The node ids used by this peer
|
||||||
#[schemars(with = "Vec<String>")]
|
#[schemars(with = "Vec<String>")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string[]"))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(type = "string[]"))]
|
||||||
pub node_ids: Vec<TypedKey>,
|
pub node_ids: Vec<TypedKey>,
|
||||||
/// The peer's human readable address.
|
/// The peer's human readable address.
|
||||||
pub peer_address: String,
|
pub peer_address: String,
|
||||||
@ -108,7 +108,7 @@ pub struct PeerTableData {
|
|||||||
|
|
||||||
/// Describe the current network state of the Veilid node
|
/// Describe the current network state of the Veilid node
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidStateNetwork {
|
pub struct VeilidStateNetwork {
|
||||||
/// If the network has been started or not.
|
/// If the network has been started or not.
|
||||||
pub started: bool,
|
pub started: bool,
|
||||||
@ -123,7 +123,7 @@ pub struct VeilidStateNetwork {
|
|||||||
|
|
||||||
/// Describe a private route change that has happened
|
/// Describe a private route change that has happened
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidRouteChange {
|
pub struct VeilidRouteChange {
|
||||||
/// If a private route that was allocated has died, it is listed here.
|
/// If a private route that was allocated has died, it is listed here.
|
||||||
#[schemars(with = "Vec<String>")]
|
#[schemars(with = "Vec<String>")]
|
||||||
@ -138,7 +138,7 @@ pub struct VeilidRouteChange {
|
|||||||
/// add the ability to change the configuration or have it changed by the Veilid node
|
/// add the ability to change the configuration or have it changed by the Veilid node
|
||||||
/// itself during runtime.
|
/// itself during runtime.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidStateConfig {
|
pub struct VeilidStateConfig {
|
||||||
/// If the Veilid node configuration has changed the full new config will be here.
|
/// If the Veilid node configuration has changed the full new config will be here.
|
||||||
pub config: VeilidConfigInner,
|
pub config: VeilidConfigInner,
|
||||||
@ -146,7 +146,7 @@ pub struct VeilidStateConfig {
|
|||||||
|
|
||||||
/// Describe when DHT records have subkey values changed
|
/// Describe when DHT records have subkey values changed
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidValueChange {
|
pub struct VeilidValueChange {
|
||||||
/// The DHT Record key that changed
|
/// The DHT Record key that changed
|
||||||
#[schemars(with = "String")]
|
#[schemars(with = "String")]
|
||||||
@ -167,7 +167,7 @@ pub struct VeilidValueChange {
|
|||||||
/// An update from the veilid-core to the host application describing a change
|
/// An update from the veilid-core to the host application describing a change
|
||||||
/// to the internal state of the Veilid node.
|
/// to the internal state of the Veilid node.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(into_wasm_abi))]
|
||||||
#[serde(tag = "kind")]
|
#[serde(tag = "kind")]
|
||||||
pub enum VeilidUpdate {
|
pub enum VeilidUpdate {
|
||||||
Log(Box<VeilidLog>),
|
Log(Box<VeilidLog>),
|
||||||
@ -184,7 +184,7 @@ from_impl_to_jsvalue!(VeilidUpdate);
|
|||||||
|
|
||||||
/// A queriable state of the internals of veilid-core.
|
/// A queriable state of the internals of veilid-core.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify), tsify(into_wasm_abi))]
|
||||||
pub struct VeilidState {
|
pub struct VeilidState {
|
||||||
pub attachment: Box<VeilidStateAttachment>,
|
pub attachment: Box<VeilidStateAttachment>,
|
||||||
pub network: Box<VeilidStateNetwork>,
|
pub network: Box<VeilidStateNetwork>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(not(target_arch = "wasm32"))] {
|
if #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] {
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
@ -31,12 +31,12 @@ pub type ConfigCallback = Arc<dyn Fn(String) -> ConfigCallbackReturn + Send + Sy
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigHTTPS {
|
pub struct VeilidConfigHTTPS {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub url: Option<String>, // Fixed URL is not optional for TLS-based protocols and is dynamically validated
|
pub url: Option<String>, // Fixed URL is not optional for TLS-based protocols and is dynamically validated
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ impl Default for VeilidConfigHTTPS {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigHTTP {
|
pub struct VeilidConfigHTTP {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ impl Default for VeilidConfigHTTP {
|
|||||||
/// To be implemented...
|
/// To be implemented...
|
||||||
///
|
///
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigApplication {
|
pub struct VeilidConfigApplication {
|
||||||
pub https: VeilidConfigHTTPS,
|
pub https: VeilidConfigHTTPS,
|
||||||
pub http: VeilidConfigHTTP,
|
pub http: VeilidConfigHTTP,
|
||||||
@ -106,19 +106,19 @@ pub struct VeilidConfigApplication {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigUDP {
|
pub struct VeilidConfigUDP {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub socket_pool_size: u32,
|
pub socket_pool_size: u32,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub public_address: Option<String>,
|
pub public_address: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VeilidConfigUDP {
|
impl Default for VeilidConfigUDP {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let enabled = false;
|
let enabled = false;
|
||||||
} else {
|
} else {
|
||||||
let enabled = true;
|
let enabled = true;
|
||||||
@ -144,20 +144,20 @@ impl Default for VeilidConfigUDP {
|
|||||||
/// public_address: ''
|
/// public_address: ''
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigTCP {
|
pub struct VeilidConfigTCP {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub public_address: Option<String>,
|
pub public_address: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VeilidConfigTCP {
|
impl Default for VeilidConfigTCP {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let connect = false;
|
let connect = false;
|
||||||
let listen = false;
|
let listen = false;
|
||||||
} else {
|
} else {
|
||||||
@ -187,7 +187,7 @@ impl Default for VeilidConfigTCP {
|
|||||||
/// url: 'ws://localhost:5150/ws'
|
/// url: 'ws://localhost:5150/ws'
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
|
|
||||||
pub struct VeilidConfigWS {
|
pub struct VeilidConfigWS {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
@ -195,14 +195,14 @@ pub struct VeilidConfigWS {
|
|||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VeilidConfigWS {
|
impl Default for VeilidConfigWS {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let connect = true;
|
let connect = true;
|
||||||
let listen = false;
|
let listen = false;
|
||||||
} else {
|
} else {
|
||||||
@ -233,7 +233,7 @@ impl Default for VeilidConfigWS {
|
|||||||
/// url: ''
|
/// url: ''
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
|
|
||||||
pub struct VeilidConfigWSS {
|
pub struct VeilidConfigWSS {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
@ -241,7 +241,7 @@ pub struct VeilidConfigWSS {
|
|||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub url: Option<String>, // Fixed URL is not optional for TLS-based protocols and is dynamically validated
|
pub url: Option<String>, // Fixed URL is not optional for TLS-based protocols and is dynamically validated
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ impl Default for VeilidConfigWSS {
|
|||||||
/// sort out which protocol is used for each peer connection.
|
/// sort out which protocol is used for each peer connection.
|
||||||
///
|
///
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
|
|
||||||
pub struct VeilidConfigProtocol {
|
pub struct VeilidConfigProtocol {
|
||||||
pub udp: VeilidConfigUDP,
|
pub udp: VeilidConfigUDP,
|
||||||
@ -284,7 +284,7 @@ pub struct VeilidConfigProtocol {
|
|||||||
/// connection_initial_timeout_ms: 2000
|
/// connection_initial_timeout_ms: 2000
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigTLS {
|
pub struct VeilidConfigTLS {
|
||||||
pub certificate_path: String,
|
pub certificate_path: String,
|
||||||
pub private_key_path: String,
|
pub private_key_path: String,
|
||||||
@ -301,7 +301,7 @@ impl Default for VeilidConfigTLS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), allow(unused_variables))]
|
||||||
pub fn get_default_ssl_directory(
|
pub fn get_default_ssl_directory(
|
||||||
program_name: &str,
|
program_name: &str,
|
||||||
organization: &str,
|
organization: &str,
|
||||||
@ -309,7 +309,7 @@ pub fn get_default_ssl_directory(
|
|||||||
sub_path: &str,
|
sub_path: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
} else {
|
} else {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@ -327,7 +327,7 @@ pub fn get_default_ssl_directory(
|
|||||||
/// If you change the count/fanout/timeout parameters, you may render your node inoperable
|
/// If you change the count/fanout/timeout parameters, you may render your node inoperable
|
||||||
/// for correct DHT operations.
|
/// for correct DHT operations.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigDHT {
|
pub struct VeilidConfigDHT {
|
||||||
pub max_find_node_count: u32,
|
pub max_find_node_count: u32,
|
||||||
pub resolve_node_timeout_ms: u32,
|
pub resolve_node_timeout_ms: u32,
|
||||||
@ -356,7 +356,7 @@ pub struct VeilidConfigDHT {
|
|||||||
impl Default for VeilidConfigDHT {
|
impl Default for VeilidConfigDHT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let local_subkey_cache_size = 128;
|
let local_subkey_cache_size = 128;
|
||||||
let local_max_subkey_cache_memory_mb = 256;
|
let local_max_subkey_cache_memory_mb = 256;
|
||||||
let remote_subkey_cache_size = 64;
|
let remote_subkey_cache_size = 64;
|
||||||
@ -411,13 +411,13 @@ impl Default for VeilidConfigDHT {
|
|||||||
/// Configure RPC.
|
/// Configure RPC.
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigRPC {
|
pub struct VeilidConfigRPC {
|
||||||
pub concurrency: u32,
|
pub concurrency: u32,
|
||||||
pub queue_size: u32,
|
pub queue_size: u32,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub max_timestamp_behind_ms: Option<u32>,
|
pub max_timestamp_behind_ms: Option<u32>,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub max_timestamp_ahead_ms: Option<u32>,
|
pub max_timestamp_ahead_ms: Option<u32>,
|
||||||
pub timeout_ms: u32,
|
pub timeout_ms: u32,
|
||||||
pub max_route_hop_count: u8,
|
pub max_route_hop_count: u8,
|
||||||
@ -441,7 +441,7 @@ impl Default for VeilidConfigRPC {
|
|||||||
/// Configure the network routing table.
|
/// Configure the network routing table.
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigRoutingTable {
|
pub struct VeilidConfigRoutingTable {
|
||||||
#[schemars(with = "Vec<String>")]
|
#[schemars(with = "Vec<String>")]
|
||||||
pub node_id: TypedKeyGroup,
|
pub node_id: TypedKeyGroup,
|
||||||
@ -460,7 +460,7 @@ pub struct VeilidConfigRoutingTable {
|
|||||||
impl Default for VeilidConfigRoutingTable {
|
impl Default for VeilidConfigRoutingTable {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let bootstrap = vec!["ws://bootstrap.veilid.net:5150/ws".to_string()];
|
let bootstrap = vec!["ws://bootstrap.veilid.net:5150/ws".to_string()];
|
||||||
} else {
|
} else {
|
||||||
let bootstrap = vec!["bootstrap.veilid.net".to_string()];
|
let bootstrap = vec!["bootstrap.veilid.net".to_string()];
|
||||||
@ -481,7 +481,7 @@ impl Default for VeilidConfigRoutingTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigNetwork {
|
pub struct VeilidConfigNetwork {
|
||||||
pub connection_initial_timeout_ms: u32,
|
pub connection_initial_timeout_ms: u32,
|
||||||
pub connection_inactivity_timeout_ms: u32,
|
pub connection_inactivity_timeout_ms: u32,
|
||||||
@ -492,7 +492,7 @@ pub struct VeilidConfigNetwork {
|
|||||||
pub client_allowlist_timeout_ms: u32,
|
pub client_allowlist_timeout_ms: u32,
|
||||||
pub reverse_connection_receipt_time_ms: u32,
|
pub reverse_connection_receipt_time_ms: u32,
|
||||||
pub hole_punch_receipt_time_ms: u32,
|
pub hole_punch_receipt_time_ms: u32,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub network_key_password: Option<String>,
|
pub network_key_password: Option<String>,
|
||||||
pub routing_table: VeilidConfigRoutingTable,
|
pub routing_table: VeilidConfigRoutingTable,
|
||||||
pub rpc: VeilidConfigRPC,
|
pub rpc: VeilidConfigRPC,
|
||||||
@ -532,13 +532,13 @@ impl Default for VeilidConfigNetwork {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigTableStore {
|
pub struct VeilidConfigTableStore {
|
||||||
pub directory: String,
|
pub directory: String,
|
||||||
pub delete: bool,
|
pub delete: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), allow(unused_variables))]
|
||||||
fn get_default_store_path(
|
fn get_default_store_path(
|
||||||
program_name: &str,
|
program_name: &str,
|
||||||
organization: &str,
|
organization: &str,
|
||||||
@ -546,7 +546,7 @@ fn get_default_store_path(
|
|||||||
store_type: &str,
|
store_type: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
} else {
|
} else {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@ -561,7 +561,7 @@ fn get_default_store_path(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigBlockStore {
|
pub struct VeilidConfigBlockStore {
|
||||||
pub directory: String,
|
pub directory: String,
|
||||||
pub delete: bool,
|
pub delete: bool,
|
||||||
@ -577,14 +577,14 @@ impl Default for VeilidConfigBlockStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigProtectedStore {
|
pub struct VeilidConfigProtectedStore {
|
||||||
pub allow_insecure_fallback: bool,
|
pub allow_insecure_fallback: bool,
|
||||||
pub always_use_insecure_storage: bool,
|
pub always_use_insecure_storage: bool,
|
||||||
pub directory: String,
|
pub directory: String,
|
||||||
pub delete: bool,
|
pub delete: bool,
|
||||||
pub device_encryption_key_password: String,
|
pub device_encryption_key_password: String,
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(optional))]
|
||||||
pub new_device_encryption_key_password: Option<String>,
|
pub new_device_encryption_key_password: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,14 +602,14 @@ impl Default for VeilidConfigProtectedStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigCapabilities {
|
pub struct VeilidConfigCapabilities {
|
||||||
pub disable: Vec<FourCC>,
|
pub disable: Vec<FourCC>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(namespace, from_wasm_abi))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), tsify(namespace, from_wasm_abi))]
|
||||||
pub enum VeilidConfigLogLevel {
|
pub enum VeilidConfigLogLevel {
|
||||||
Off,
|
Off,
|
||||||
Error,
|
Error,
|
||||||
@ -698,7 +698,7 @@ impl fmt::Display for VeilidConfigLogLevel {
|
|||||||
|
|
||||||
/// Top level of the Veilid configuration tree
|
/// Top level of the Veilid configuration tree
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidConfigInner {
|
pub struct VeilidConfigInner {
|
||||||
/// An identifier used to describe the program using veilid-core.
|
/// An identifier used to describe the program using veilid-core.
|
||||||
/// Used to partition storage locations in places like the ProtectedStore.
|
/// Used to partition storage locations in places like the ProtectedStore.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
pub use tsify::*;
|
pub use tsify::*;
|
||||||
pub use wasm_bindgen::prelude::*;
|
pub use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Test suite for the Web and headless browsers.
|
//! Test suite for the Web and headless browsers.
|
||||||
#![cfg(target_arch = "wasm32")]
|
#![cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
use parking_lot::Once;
|
use parking_lot::Once;
|
||||||
|
@ -50,7 +50,7 @@ tracing-flame = "0.2.0"
|
|||||||
|
|
||||||
# Dependencies for native builds only
|
# Dependencies for native builds only
|
||||||
# Linux, Windows, Mac, iOS, Android
|
# Linux, Windows, Mac, iOS, Android
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
|
||||||
tracing-opentelemetry = "0.21"
|
tracing-opentelemetry = "0.21"
|
||||||
opentelemetry = { version = "0.20" }
|
opentelemetry = { version = "0.20" }
|
||||||
opentelemetry-otlp = { version = "0.13" }
|
opentelemetry-otlp = { version = "0.13" }
|
||||||
@ -68,7 +68,7 @@ libc-print = { version = "0.1.23", optional = true }
|
|||||||
|
|
||||||
|
|
||||||
# Dependencies for WASM builds only
|
# Dependencies for WASM builds only
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
|
||||||
|
|
||||||
# Dependencies for Android builds only
|
# Dependencies for Android builds only
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
|
@ -75,7 +75,7 @@ flume = { version = "0.11.0", features = ["async"] }
|
|||||||
|
|
||||||
# Dependencies for native builds only
|
# Dependencies for native builds only
|
||||||
# Linux, Windows, Mac, iOS, Android
|
# Linux, Windows, Mac, iOS, Android
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
|
||||||
async-io = { version = "1.13.0" }
|
async-io = { version = "1.13.0" }
|
||||||
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
|
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
@ -93,7 +93,7 @@ tokio-util = { version = "0.7.11", features = ["compat"], optional = true }
|
|||||||
tokio-stream = { version = "0.1.15", features = ["net"], optional = true }
|
tokio-stream = { version = "0.1.15", features = ["net"], optional = true }
|
||||||
|
|
||||||
# Dependencies for WASM builds only
|
# Dependencies for WASM builds only
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
|
||||||
wasm-bindgen = "0.2.92"
|
wasm-bindgen = "0.2.92"
|
||||||
js-sys = "0.3.70"
|
js-sys = "0.3.70"
|
||||||
wasm-bindgen-futures = "0.4.42"
|
wasm-bindgen-futures = "0.4.42"
|
||||||
@ -133,11 +133,11 @@ ifstructs = "0.1.1"
|
|||||||
|
|
||||||
### DEV DEPENDENCIES
|
### DEV DEPENDENCIES
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies]
|
||||||
simplelog = { version = "0.12.2", features = ["test"] }
|
simplelog = { version = "0.12.2", features = ["test"] }
|
||||||
serial_test = "2.0.0"
|
serial_test = "2.0.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
|
||||||
serial_test = { version = "2.0.0", default-features = false, features = [
|
serial_test = { version = "2.0.0", default-features = false, features = [
|
||||||
"async",
|
"async",
|
||||||
] }
|
] }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
|
|
||||||
pub fn interval<F, FUT>(name: &str, freq_ms: u32, callback: F) -> SendPinBoxFuture<()>
|
pub fn interval<F, FUT>(name: &str, freq_ms: u32, callback: F) -> SendPinBoxFuture<()>
|
||||||
where
|
where
|
||||||
|
@ -42,13 +42,12 @@ pub mod ipc;
|
|||||||
pub mod must_join_handle;
|
pub mod must_join_handle;
|
||||||
pub mod must_join_single_future;
|
pub mod must_join_single_future;
|
||||||
pub mod mutable_future;
|
pub mod mutable_future;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub mod network_interfaces;
|
pub mod network_interfaces;
|
||||||
pub mod network_result;
|
pub mod network_result;
|
||||||
pub mod random;
|
pub mod random;
|
||||||
pub mod single_shot_eventual;
|
pub mod single_shot_eventual;
|
||||||
pub mod sleep;
|
pub mod sleep;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
pub mod socket_tools;
|
pub mod socket_tools;
|
||||||
pub mod spawn;
|
pub mod spawn;
|
||||||
pub mod split_url;
|
pub mod split_url;
|
||||||
@ -59,7 +58,7 @@ pub mod timeout_or;
|
|||||||
pub mod timestamp;
|
pub mod timestamp;
|
||||||
pub mod tools;
|
pub mod tools;
|
||||||
pub mod virtual_network;
|
pub mod virtual_network;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
|
|
||||||
pub type PinBox<T> = Pin<Box<T>>;
|
pub type PinBox<T> = Pin<Box<T>>;
|
||||||
@ -129,7 +128,7 @@ pub use async_lock::RwLockReadGuard as AsyncRwLockReadGuard;
|
|||||||
pub use async_lock::RwLockWriteGuard as AsyncRwLockWriteGuard;
|
pub use async_lock::RwLockWriteGuard as AsyncRwLockWriteGuard;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use async_lock::Mutex as AsyncMutex;
|
pub use async_lock::Mutex as AsyncMutex;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
@ -222,7 +221,6 @@ pub use must_join_single_future::*;
|
|||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use mutable_future::*;
|
pub use mutable_future::*;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub use network_interfaces::*;
|
pub use network_interfaces::*;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use network_result::*;
|
pub use network_result::*;
|
||||||
@ -233,7 +231,7 @@ pub use single_shot_eventual::*;
|
|||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use sleep::*;
|
pub use sleep::*;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
pub use socket_tools::*;
|
pub use socket_tools::*;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use spawn::*;
|
pub use spawn::*;
|
||||||
@ -252,7 +250,7 @@ pub use timestamp::*;
|
|||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use tools::*;
|
pub use tools::*;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
pub use wasm::*;
|
pub use wasm::*;
|
||||||
|
|
||||||
// Tests must be public for wasm-pack tests
|
// Tests must be public for wasm-pack tests
|
||||||
|
@ -22,7 +22,7 @@ impl<T> MustJoinHandle<T> {
|
|||||||
self.join_handle = None;
|
self.join_handle = None;
|
||||||
} else if #[cfg(feature="rt-tokio")] {
|
} else if #[cfg(feature="rt-tokio")] {
|
||||||
self.join_handle = None;
|
self.join_handle = None;
|
||||||
} else if #[cfg(target_arch = "wasm32")] {
|
} else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
if let Some(jh) = self.join_handle.take() {
|
if let Some(jh) = self.join_handle.take() {
|
||||||
jh.detach();
|
jh.detach();
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ impl<T> MustJoinHandle<T> {
|
|||||||
let _ = jh.await;
|
let _ = jh.await;
|
||||||
self.completed = true;
|
self.completed = true;
|
||||||
}
|
}
|
||||||
} else if #[cfg(target_arch = "wasm32")] {
|
} else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
drop(self.join_handle.take());
|
drop(self.join_handle.take());
|
||||||
self.completed = true;
|
self.completed = true;
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +94,7 @@ impl<T: 'static> Future for MustJoinHandle<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if #[cfg(target_arch = "wasm32")] {
|
} else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
Poll::Ready(t)
|
Poll::Ready(t)
|
||||||
} else {
|
} else {
|
||||||
compile_error!("needs executor implementation");
|
compile_error!("needs executor implementation");
|
||||||
|
@ -19,6 +19,9 @@ cfg_if::cfg_if! {
|
|||||||
mod openbsd;
|
mod openbsd;
|
||||||
mod sockaddr_tools;
|
mod sockaddr_tools;
|
||||||
use self::openbsd::PlatformSupportOpenBSD as PlatformSupport;
|
use self::openbsd::PlatformSupportOpenBSD as PlatformSupport;
|
||||||
|
} else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
|
mod wasm;
|
||||||
|
use self::wasm::PlatformSupportWasm as PlatformSupport;
|
||||||
} else {
|
} else {
|
||||||
compile_error!("No network interfaces support for this platform!");
|
compile_error!("No network interfaces support for this platform!");
|
||||||
}
|
}
|
||||||
|
18
veilid-tools/src/network_interfaces/wasm.rs
Normal file
18
veilid-tools/src/network_interfaces/wasm.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use super::*;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
|
pub struct PlatformSupportWasm {}
|
||||||
|
|
||||||
|
impl PlatformSupportWasm {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
PlatformSupportWasm {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_interfaces(
|
||||||
|
&mut self,
|
||||||
|
interfaces: &mut BTreeMap<String, NetworkInterface>,
|
||||||
|
) -> io::Result<()> {
|
||||||
|
interfaces.clear();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ pub trait IoNetworkResultExt<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn io_error_kind_from_error<T>(e: io::Error) -> io::Result<NetworkResult<T>> {
|
fn io_error_kind_from_error<T>(e: io::Error) -> io::Result<NetworkResult<T>> {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
if let Some(os_err) = e.raw_os_error() {
|
if let Some(os_err) = e.raw_os_error() {
|
||||||
if os_err == libc::EHOSTUNREACH || os_err == libc::ENETUNREACH {
|
if os_err == libc::EHOSTUNREACH || os_err == libc::ENETUNREACH {
|
||||||
return Ok(NetworkResult::NoConnection(e));
|
return Ok(NetworkResult::NoConnection(e));
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use async_executors::{Bindgen, Timer};
|
use async_executors::{Bindgen, Timer};
|
||||||
|
|
||||||
pub async fn sleep(millis: u32) {
|
pub async fn sleep(millis: u32) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use async_executors::{Bindgen, LocalSpawnHandleExt, SpawnHandleExt};
|
use async_executors::{Bindgen, LocalSpawnHandleExt, SpawnHandleExt};
|
||||||
|
|
||||||
pub fn spawn<Out>(_name: &str, future: impl Future<Output = Out> + Send + 'static) -> MustJoinHandle<Out>
|
pub fn spawn<Out>(_name: &str, future: impl Future<Output = Out> + Send + 'static) -> MustJoinHandle<Out>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use js_sys::*;
|
use js_sys::*;
|
||||||
} else {
|
} else {
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
@ -293,7 +293,7 @@ pub async fn test_timeout() {
|
|||||||
pub async fn test_sleep() {
|
pub async fn test_sleep() {
|
||||||
info!("testing sleep");
|
info!("testing sleep");
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
|
|
||||||
let t1 = Date::now();
|
let t1 = Date::now();
|
||||||
sleep(1000).await;
|
sleep(1000).await;
|
||||||
@ -548,7 +548,7 @@ pub async fn test_all() {
|
|||||||
test_get_random_u64().await;
|
test_get_random_u64().await;
|
||||||
test_get_random_u32().await;
|
test_get_random_u32().await;
|
||||||
test_sleep().await;
|
test_sleep().await;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
test_must_join_single_future().await;
|
test_must_join_single_future().await;
|
||||||
test_eventual().await;
|
test_eventual().await;
|
||||||
test_eventual_value().await;
|
test_eventual_value().await;
|
||||||
|
@ -3,7 +3,7 @@ mod android;
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
#[cfg(all(target_os = "ios", feature = "veilid_tools_ios_tests"))]
|
#[cfg(all(target_os = "ios", feature = "veilid_tools_ios_tests"))]
|
||||||
mod ios;
|
mod ios;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
mod native;
|
mod native;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Test suite for Native
|
//! Test suite for Native
|
||||||
#![cfg(not(target_arch = "wasm32"))]
|
#![cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
|
|
||||||
mod test_assembly_buffer;
|
mod test_assembly_buffer;
|
||||||
mod test_async_peek_stream;
|
mod test_async_peek_stream;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(target_arch = "wasm32"))] {
|
if #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] {
|
||||||
use network_interfaces::NetworkInterfaces;
|
use network_interfaces::NetworkInterfaces;
|
||||||
|
|
||||||
pub async fn test_network_interfaces() {
|
pub async fn test_network_interfaces() {
|
||||||
@ -24,6 +24,6 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_all() {
|
pub async fn test_all() {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
test_network_interfaces().await;
|
test_network_interfaces().await;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use futures_util::future::{select, Either};
|
use futures_util::future::{select, Either};
|
||||||
|
|
||||||
pub async fn timeout<F, T>(dur_ms: u32, f: F) -> Result<T, TimeoutError>
|
pub async fn timeout<F, T>(dur_ms: u32, f: F) -> Result<T, TimeoutError>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use js_sys::Date;
|
use js_sys::Date;
|
||||||
|
|
||||||
pub fn get_timestamp() -> u64 {
|
pub fn get_timestamp() -> u64 {
|
||||||
|
@ -115,7 +115,7 @@ pub fn system_boxed<'a, Out>(
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(target_arch = "wasm32"))] {
|
if #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] {
|
||||||
pub fn get_concurrency() -> u32 {
|
pub fn get_concurrency() -> u32 {
|
||||||
std::thread::available_parallelism()
|
std::thread::available_parallelism()
|
||||||
.map(|x| x.get())
|
.map(|x| x.get())
|
||||||
@ -259,7 +259,7 @@ pub fn compatible_unspecified_socket_addr(socket_addr: &SocketAddr) -> SocketAdd
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(target_arch = "wasm32"))] {
|
if #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] {
|
||||||
use std::net::UdpSocket;
|
use std::net::UdpSocket;
|
||||||
|
|
||||||
static IPV6_IS_SUPPORTED: Mutex<Option<bool>> = Mutex::new(None);
|
static IPV6_IS_SUPPORTED: Mutex<Option<bool>> = Mutex::new(None);
|
||||||
@ -308,7 +308,7 @@ pub fn listen_address_to_socket_addrs(listen_address: &str) -> Result<Vec<Socket
|
|||||||
format!("{}:0", listen_address)
|
format!("{}:0", listen_address)
|
||||||
};
|
};
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
vec![SocketAddr::from_str(&listen_address_with_port).map_err(|e| format!("Unable to parse address: {}",e))?]
|
vec![SocketAddr::from_str(&listen_address_with_port).map_err(|e| format!("Unable to parse address: {}",e))?]
|
||||||
} else {
|
} else {
|
||||||
@ -481,7 +481,7 @@ pub fn is_debug_backtrace_enabled() -> bool {
|
|||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(debug_assertions)] {
|
if #[cfg(debug_assertions)] {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
let rbenv = get_wasm_global_string_value("RUST_BACKTRACE").unwrap_or_default();
|
let rbenv = get_wasm_global_string_value("RUST_BACKTRACE").unwrap_or_default();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -189,7 +189,7 @@ impl RouterClient {
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Public interface
|
// Public interface
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
|
||||||
pub async fn router_connect_tcp<H: ToSocketAddrs>(host: H) -> io::Result<RouterClient> {
|
pub async fn router_connect_tcp<H: ToSocketAddrs>(host: H) -> io::Result<RouterClient> {
|
||||||
let addrs = host.to_socket_addrs()?.collect::<Vec<_>>();
|
let addrs = host.to_socket_addrs()?.collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -241,11 +241,52 @@ impl RouterClient {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
pub async fn router_connect_ws<H: AsRef<str>>(host: H) -> io::Result<RouterClient> {
|
pub async fn router_connect_ws<R: AsRef<str>>(request: R) -> io::Result<RouterClient> {
|
||||||
let host = host.as_ref();
|
let request = request.as_ref();
|
||||||
|
|
||||||
Ok(RouterClient {})
|
// Connect to RouterServer
|
||||||
|
let wsio_reader;
|
||||||
|
let wsio_writer;
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(feature="rt-wasm-bindgen")] {
|
||||||
|
use ws_stream_wasm::*;
|
||||||
|
let (_wsmeta, wsio) = WsMeta::connect(request, None)
|
||||||
|
.await.map_err(ws_err_to_io_error)?;
|
||||||
|
use futures_util::io::AsyncReadExt;
|
||||||
|
(wsio_reader, wsio_writer) = wsio.into_io().split();
|
||||||
|
} else {
|
||||||
|
compile_error!("must choose an executor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create channels
|
||||||
|
let (client_sender, server_receiver) = flume::unbounded::<Bytes>();
|
||||||
|
|
||||||
|
// Create stopper
|
||||||
|
let stop_source = StopSource::new();
|
||||||
|
|
||||||
|
// Create router operation waiter
|
||||||
|
let router_op_waiter = RouterOpWaiter::new();
|
||||||
|
|
||||||
|
// Spawn a client connection handler
|
||||||
|
let jh_handler = spawn(
|
||||||
|
"RouterClient server processor",
|
||||||
|
Self::run_server_processor(
|
||||||
|
wsio_reader,
|
||||||
|
wsio_writer,
|
||||||
|
server_receiver,
|
||||||
|
router_op_waiter.clone(),
|
||||||
|
stop_source.token(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(Self::new(
|
||||||
|
client_sender,
|
||||||
|
router_op_waiter,
|
||||||
|
jh_handler,
|
||||||
|
stop_source,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn disconnect(self) {
|
pub async fn disconnect(self) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use core::sync::atomic::{AtomicI8, AtomicU32, Ordering};
|
use core::sync::atomic::{AtomicI8, AtomicU32, Ordering};
|
||||||
use js_sys::{global, Reflect};
|
use js_sys::{global, Reflect};
|
||||||
|
use std::io;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
use ws_stream_wasm::WsErr;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -89,3 +91,26 @@ pub fn get_concurrency() -> u32 {
|
|||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ws_err_to_io_error(err: WsErr) -> io::Error {
|
||||||
|
match err {
|
||||||
|
WsErr::InvalidWsState { supplied: _ } => {
|
||||||
|
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
||||||
|
}
|
||||||
|
WsErr::ConnectionNotOpen => io::Error::new(io::ErrorKind::NotConnected, err.to_string()),
|
||||||
|
WsErr::InvalidUrl { supplied: _ } => {
|
||||||
|
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
||||||
|
}
|
||||||
|
WsErr::InvalidCloseCode { supplied: _ } => {
|
||||||
|
io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
|
||||||
|
}
|
||||||
|
WsErr::ReasonStringToLong => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
||||||
|
WsErr::ConnectionFailed { event: _ } => {
|
||||||
|
io::Error::new(io::ErrorKind::ConnectionRefused, err.to_string())
|
||||||
|
}
|
||||||
|
WsErr::InvalidEncoding => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
||||||
|
WsErr::CantDecodeBlob => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
||||||
|
WsErr::UnknownDataType => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
||||||
|
_ => io::Error::new(io::ErrorKind::Other, err.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Test suite for the Web and headless browsers.
|
//! Test suite for the Web and headless browsers.
|
||||||
#![cfg(target_arch = "wasm32")]
|
#![cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
|
|
||||||
use cfg_if::*;
|
use cfg_if::*;
|
||||||
use parking_lot::Once;
|
use parking_lot::Once;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
#![allow(clippy::comparison_chain, clippy::upper_case_acronyms)]
|
#![allow(clippy::comparison_chain, clippy::upper_case_acronyms)]
|
||||||
#![deny(unused_must_use)]
|
#![deny(unused_must_use)]
|
||||||
#![cfg(target_arch = "wasm32")]
|
#![cfg(all(target_arch = "wasm32", target_os = "unknown"))]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
/// Veilid WASM Bindings for Flutter/Dart, as well as Native Javascript
|
/// Veilid WASM Bindings for Flutter/Dart, as well as Native Javascript
|
||||||
@ -142,7 +142,7 @@ where
|
|||||||
// WASM-specific
|
// WASM-specific
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidWASMConfigLoggingPerformance {
|
pub struct VeilidWASMConfigLoggingPerformance {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: veilid_core::VeilidConfigLogLevel,
|
pub level: veilid_core::VeilidConfigLogLevel,
|
||||||
@ -152,7 +152,7 @@ pub struct VeilidWASMConfigLoggingPerformance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidWASMConfigLoggingAPI {
|
pub struct VeilidWASMConfigLoggingAPI {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: veilid_core::VeilidConfigLogLevel,
|
pub level: veilid_core::VeilidConfigLogLevel,
|
||||||
@ -160,28 +160,35 @@ pub struct VeilidWASMConfigLoggingAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
pub struct VeilidWASMConfigLogging {
|
pub struct VeilidWASMConfigLogging {
|
||||||
pub performance: VeilidWASMConfigLoggingPerformance,
|
pub performance: VeilidWASMConfigLoggingPerformance,
|
||||||
pub api: VeilidWASMConfigLoggingAPI,
|
pub api: VeilidWASMConfigLoggingAPI,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
|
derive(Tsify),
|
||||||
|
tsify(from_wasm_abi)
|
||||||
|
)]
|
||||||
pub struct VeilidWASMConfig {
|
pub struct VeilidWASMConfig {
|
||||||
pub logging: VeilidWASMConfigLogging,
|
pub logging: VeilidWASMConfigLogging,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
target_arch = "wasm32",
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
derive(Tsify),
|
derive(Tsify),
|
||||||
tsify(from_wasm_abi, into_wasm_abi)
|
tsify(from_wasm_abi, into_wasm_abi)
|
||||||
)]
|
)]
|
||||||
pub struct VeilidRouteBlob {
|
pub struct VeilidRouteBlob {
|
||||||
pub route_id: veilid_core::RouteId,
|
pub route_id: veilid_core::RouteId,
|
||||||
#[serde(with = "veilid_core::as_human_base64")]
|
#[serde(with = "veilid_core::as_human_base64")]
|
||||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", target_os = "unknown"),
|
||||||
|
tsify(type = "string")
|
||||||
|
)]
|
||||||
pub blob: Vec<u8>,
|
pub blob: Vec<u8>,
|
||||||
}
|
}
|
||||||
from_impl_to_jsvalue!(VeilidRouteBlob);
|
from_impl_to_jsvalue!(VeilidRouteBlob);
|
||||||
@ -1587,7 +1594,7 @@ pub fn veilid_version_string() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), derive(Tsify))]
|
||||||
#[tsify(into_wasm_abi)]
|
#[tsify(into_wasm_abi)]
|
||||||
pub struct VeilidVersion {
|
pub struct VeilidVersion {
|
||||||
pub major: u32,
|
pub major: u32,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
|
||||||
pub use wasm_bindgen::prelude::*;
|
pub use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
macro_rules! from_impl_to_jsvalue {
|
macro_rules! from_impl_to_jsvalue {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user