(wasm) Add VeilidCrypto class, refine interfaces for VeilidRoutingContext
This commit is contained in:
@@ -14,6 +14,7 @@ use super::*;
|
||||
pub struct AlignedU64(
|
||||
#[serde(with = "as_human_string")]
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
||||
u64,
|
||||
);
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ use super::*;
|
||||
pub struct VeilidAppMessage {
|
||||
#[serde(with = "as_human_opt_string")]
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
||||
sender: Option<TypedKey>,
|
||||
|
||||
#[serde(with = "as_human_base64")]
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
||||
message: Vec<u8>,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@ use super::*;
|
||||
|
||||
/// DHT Record Descriptor
|
||||
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
#[cfg_attr(
|
||||
target_arch = "wasm32",
|
||||
derive(Tsify),
|
||||
tsify(from_wasm_abi, into_wasm_abi)
|
||||
)]
|
||||
pub struct DHTRecordDescriptor {
|
||||
/// DHT Key = Hash(ownerKeyKind) of: [ ownerKeyValue, schema ]
|
||||
#[schemars(with = "String")]
|
||||
@@ -15,11 +19,12 @@ pub struct DHTRecordDescriptor {
|
||||
/// If this key is being created: Some(the secret key of the owner)
|
||||
/// If this key is just being opened: None
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string | undefined"))]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
||||
owner_secret: Option<SecretKey>,
|
||||
/// The schema in use associated with the key
|
||||
schema: DHTSchema,
|
||||
}
|
||||
from_impl_to_jsvalue!(DHTRecordDescriptor);
|
||||
|
||||
impl DHTRecordDescriptor {
|
||||
pub fn new(
|
||||
|
||||
@@ -2,6 +2,7 @@ use super::*;
|
||||
|
||||
/// Default DHT Schema (DFLT)
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
||||
pub struct DHTSchemaDFLT {
|
||||
/// Owner subkey count
|
||||
pub o_cnt: u16,
|
||||
|
||||
@@ -2,9 +2,11 @@ use super::*;
|
||||
|
||||
/// Simple DHT Schema (SMPL) Member
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
||||
pub struct DHTSchemaSMPLMember {
|
||||
/// Member key
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
||||
pub m_key: PublicKey,
|
||||
/// Member subkey count
|
||||
pub m_cnt: u16,
|
||||
@@ -12,6 +14,7 @@ pub struct DHTSchemaSMPLMember {
|
||||
|
||||
/// Simple DHT Schema (SMPL)
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(from_wasm_abi))]
|
||||
pub struct DHTSchemaSMPL {
|
||||
/// Owner subkey count
|
||||
pub o_cnt: u16,
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::*;
|
||||
use veilid_api::VeilidAPIResult;
|
||||
|
||||
#[derive(Clone, Default, PartialOrd, PartialEq, Eq, Ord, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
|
||||
pub struct ValueData {
|
||||
/// An increasing sequence number to time-order the DHT record changes
|
||||
seq: ValueSeqNum,
|
||||
@@ -18,6 +18,8 @@ pub struct ValueData {
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
||||
writer: PublicKey,
|
||||
}
|
||||
from_impl_to_jsvalue!(ValueData);
|
||||
|
||||
impl ValueData {
|
||||
pub const MAX_LEN: usize = 32768;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ impl Default for SafetySelection {
|
||||
pub struct SafetySpec {
|
||||
/// preferred safety route set id if it still exists
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string | undefined"))]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
|
||||
pub preferred_route: Option<RouteId>,
|
||||
/// must be greater than 0
|
||||
pub hop_count: usize,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct LatencyStats {
|
||||
pub fastest: TimestampDuration, // fastest latency in the ROLLING_LATENCIES_SIZE last latencies
|
||||
pub average: TimestampDuration, // average latency over the ROLLING_LATENCIES_SIZE last latencies
|
||||
@@ -8,6 +9,7 @@ pub struct LatencyStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct TransferStats {
|
||||
pub total: ByteCount, // total amount transferred ever
|
||||
pub maximum: ByteCount, // maximum rate over the ROLLING_TRANSFERS_SIZE last amounts
|
||||
@@ -16,12 +18,14 @@ pub struct TransferStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct TransferStatsDownUp {
|
||||
pub down: TransferStats,
|
||||
pub up: TransferStats,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct RPCStats {
|
||||
pub messages_sent: u32, // number of rpcs that have been sent in the total_time range
|
||||
pub messages_rcvd: u32, // number of rpcs that have been received in the total_time range
|
||||
@@ -34,6 +38,7 @@ pub struct RPCStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct PeerStats {
|
||||
pub time_added: Timestamp, // when the peer was added to the routing table
|
||||
pub rpc_stats: RPCStats, // information about RPCs
|
||||
|
||||
@@ -97,6 +97,7 @@ pub struct VeilidStateConfig {
|
||||
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
|
||||
pub struct VeilidValueChange {
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
|
||||
pub key: TypedKey,
|
||||
pub subkeys: Vec<ValueSubkey>,
|
||||
pub count: u32,
|
||||
|
||||
Reference in New Issue
Block a user