(wasm) Treat arbitrary byte data as Uint8Array, instead of base64url marshalling.

This commit is contained in:
Brandon Vandegrift
2023-09-20 00:46:45 -04:00
parent a7b073cddb
commit 80afa19678
17 changed files with 452 additions and 116 deletions

View File

@@ -215,7 +215,6 @@ impl VeilidAPIError {
}
}
#[cfg_attr(target_arch = "wasm32", declare)]
pub type VeilidAPIResult<T> = Result<T, VeilidAPIError>;
impl From<std::io::Error> for VeilidAPIError {

View File

@@ -9,9 +9,13 @@ pub struct VeilidAppMessage {
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
sender: Option<TypedKey>,
#[serde(with = "as_human_base64")]
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
#[cfg_attr(
target_arch = "wasm32",
serde(with = "serde_bytes"),
tsify(type = "Uint8Array")
)]
message: Vec<u8>,
}
@@ -40,8 +44,13 @@ pub struct VeilidAppCall {
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
sender: Option<TypedKey>,
#[serde(with = "as_human_base64")]
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
#[schemars(with = "String")]
#[cfg_attr(
target_arch = "wasm32",
serde(with = "serde_bytes"),
tsify(type = "Uint8Array")
)]
message: Vec<u8>,
#[serde(with = "as_human_string")]

View File

@@ -8,9 +8,13 @@ pub struct ValueData {
seq: ValueSeqNum,
/// The contents of a DHT Record
#[serde(with = "as_human_base64")]
#[cfg_attr(not(target_arch = "wasm32"), serde(with = "as_human_base64"))]
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
#[cfg_attr(
target_arch = "wasm32",
serde(with = "serde_bytes"),
tsify(type = "Uint8Array")
)]
data: Vec<u8>,
/// The public identity key of the writer of the data