build fixes and cleanup
This commit is contained in:
committed by
Brandon Vandegrift
parent
779532b624
commit
9aeec3cfa8
@@ -105,21 +105,10 @@ macro_rules! apibail_already_initialized {
|
||||
}
|
||||
|
||||
#[derive(
|
||||
ThisError,
|
||||
Clone,
|
||||
Debug,
|
||||
PartialOrd,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Ord,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
JsonSchema,
|
||||
Tsify,
|
||||
TsifyAsync,
|
||||
ThisError, Clone, Debug, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema,
|
||||
)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
||||
#[serde(tag = "kind")]
|
||||
#[tsify(into_wasm_abi)]
|
||||
pub enum VeilidAPIError {
|
||||
#[error("Not initialized")]
|
||||
NotInitialized,
|
||||
@@ -157,6 +146,7 @@ pub enum VeilidAPIError {
|
||||
#[error("Generic: {message}")]
|
||||
Generic { message: String },
|
||||
}
|
||||
from_impl_to_jsvalue!(VeilidAPIError);
|
||||
|
||||
impl VeilidAPIError {
|
||||
pub fn not_initialized() -> Self {
|
||||
@@ -225,7 +215,7 @@ impl VeilidAPIError {
|
||||
}
|
||||
}
|
||||
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type VeilidAPIResult<T> = Result<T, VeilidAPIError>;
|
||||
|
||||
impl From<std::io::Error> for VeilidAPIError {
|
||||
|
||||
@@ -6,19 +6,9 @@ use super::*;
|
||||
/// Supports serializing to string for JSON as well, since JSON can't handle 64-bit numbers to Javascript
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Default,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Copy,
|
||||
Hash,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
JsonSchema,
|
||||
Tsify,
|
||||
Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Serialize, Deserialize, JsonSchema,
|
||||
)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
#[repr(C, align(8))]
|
||||
#[serde(transparent)]
|
||||
pub struct AlignedU64(
|
||||
@@ -128,17 +118,17 @@ impl AlignedU64 {
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Microseconds since epoch
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type Timestamp = AlignedU64;
|
||||
pub fn get_aligned_timestamp() -> Timestamp {
|
||||
get_timestamp().into()
|
||||
}
|
||||
/// Microseconds duration
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type TimestampDuration = AlignedU64;
|
||||
/// Request/Response matching id
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type OperationId = AlignedU64;
|
||||
/// Number of bytes
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type ByteCount = AlignedU64;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use super::*;
|
||||
|
||||
/// Direct statement blob passed to hosting application for processing
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidAppMessage {
|
||||
#[serde(with = "as_human_opt_string")]
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[tsify(optional)]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
||||
sender: Option<TypedKey>,
|
||||
|
||||
#[serde(with = "as_human_base64")]
|
||||
@@ -30,11 +31,12 @@ impl VeilidAppMessage {
|
||||
}
|
||||
|
||||
/// Direct question blob passed to hosting application for processing to send an eventual AppReply
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidAppCall {
|
||||
#[serde(with = "as_human_opt_string")]
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[tsify(optional)]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
||||
sender: Option<TypedKey>,
|
||||
|
||||
#[serde(with = "as_human_base64")]
|
||||
|
||||
@@ -11,8 +11,8 @@ pub use value_data::*;
|
||||
pub use value_subkey_range_set::*;
|
||||
|
||||
/// Value subkey
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type ValueSubkey = u32;
|
||||
/// Value sequence number
|
||||
#[declare]
|
||||
#[cfg_attr(target_arch = "wasm32", declare)]
|
||||
pub type ValueSeqNum = u32;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use super::*;
|
||||
use veilid_api::VeilidAPIResult;
|
||||
|
||||
#[derive(
|
||||
Clone, Default, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema, Tsify,
|
||||
)]
|
||||
#[derive(Clone, Default, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct ValueData {
|
||||
/// An increasing sequence number to time-order the DHT record changes
|
||||
seq: ValueSeqNum,
|
||||
|
||||
@@ -2,19 +2,9 @@ use super::*;
|
||||
|
||||
/// FOURCC code
|
||||
#[derive(
|
||||
Copy,
|
||||
Default,
|
||||
Clone,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
JsonSchema,
|
||||
Tsify,
|
||||
Copy, Default, Clone, Hash, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema,
|
||||
)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
#[serde(try_from = "String")]
|
||||
#[serde(into = "String")]
|
||||
pub struct FourCC(pub [u8; 4]);
|
||||
|
||||
@@ -2,9 +2,9 @@ use super::*;
|
||||
|
||||
/// Log level for VeilidCore
|
||||
#[derive(
|
||||
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize, Deserialize, JsonSchema, Tsify,
|
||||
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize, Deserialize, JsonSchema,
|
||||
)]
|
||||
#[tsify(namespace)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(namespace))]
|
||||
pub enum VeilidLogLevel {
|
||||
Error = 1,
|
||||
Warn = 2,
|
||||
@@ -80,10 +80,11 @@ impl fmt::Display for VeilidLogLevel {
|
||||
}
|
||||
}
|
||||
/// A VeilidCore log message with optional backtrace
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidLog {
|
||||
pub log_level: VeilidLogLevel,
|
||||
pub message: String,
|
||||
#[tsify(optional)]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
||||
pub backtrace: Option<String>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
use super::*;
|
||||
|
||||
/// Attachment abstraction for network 'signal strength'
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[tsify(namespace, from_wasm_abi, into_wasm_abi)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(
|
||||
target_arch = "wasm32",
|
||||
derive(Tsify),
|
||||
tsify(namespace, from_wasm_abi, into_wasm_abi)
|
||||
)]
|
||||
pub enum AttachmentState {
|
||||
Detached = 0,
|
||||
Attaching = 1,
|
||||
@@ -48,14 +52,16 @@ impl TryFrom<String> for AttachmentState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidStateAttachment {
|
||||
pub state: AttachmentState,
|
||||
pub public_internet_ready: bool,
|
||||
pub local_network_ready: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct PeerTableData {
|
||||
#[schemars(with = "Vec<String>")]
|
||||
pub node_ids: Vec<TypedKey>,
|
||||
@@ -63,7 +69,8 @@ pub struct PeerTableData {
|
||||
pub peer_stats: PeerStats,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidStateNetwork {
|
||||
pub started: bool,
|
||||
pub bps_down: ByteCount,
|
||||
@@ -71,7 +78,8 @@ pub struct VeilidStateNetwork {
|
||||
pub peers: Vec<PeerTableData>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidRouteChange {
|
||||
#[schemars(with = "Vec<String>")]
|
||||
pub dead_routes: Vec<RouteId>,
|
||||
@@ -79,12 +87,14 @@ pub struct VeilidRouteChange {
|
||||
pub dead_remote_routes: Vec<RouteId>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidStateConfig {
|
||||
pub config: VeilidConfigInner,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidValueChange {
|
||||
#[schemars(with = "String")]
|
||||
pub key: TypedKey,
|
||||
@@ -93,9 +103,9 @@ pub struct VeilidValueChange {
|
||||
pub value: ValueData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify, TsifyAsync)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
||||
#[serde(tag = "kind")]
|
||||
#[tsify(into_wasm_abi)]
|
||||
pub enum VeilidUpdate {
|
||||
Log(VeilidLog),
|
||||
AppMessage(VeilidAppMessage),
|
||||
@@ -107,11 +117,13 @@ pub enum VeilidUpdate {
|
||||
ValueChange(VeilidValueChange),
|
||||
Shutdown,
|
||||
}
|
||||
from_impl_to_jsvalue!(VeilidUpdate);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Tsify, TsifyAsync)]
|
||||
#[tsify(into_wasm_abi)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
||||
pub struct VeilidState {
|
||||
pub attachment: VeilidStateAttachment,
|
||||
pub network: VeilidStateNetwork,
|
||||
pub config: VeilidStateConfig,
|
||||
}
|
||||
from_impl_to_jsvalue!(VeilidState);
|
||||
|
||||
Reference in New Issue
Block a user