replace ipld_dagcbor for postcard

Changed files
+87 -8
client
src
+75
Cargo.lock
···
]
[[package]]
+
name = "atomic-polyfill"
+
version = "1.0.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
+
dependencies = [
+
"critical-section",
+
]
+
+
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
+
name = "hash32"
+
version = "0.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
+
dependencies = [
+
"byteorder",
+
]
+
+
[[package]]
name = "hashbrown"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
+
+
[[package]]
+
name = "heapless"
+
version = "0.7.17"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
+
dependencies = [
+
"atomic-polyfill",
+
"hash32",
+
"rustc_version",
+
"serde",
+
"spin",
+
"stable_deref_trait",
+
]
[[package]]
name = "heck"
···
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
[[package]]
+
name = "lock_api"
+
version = "0.4.13"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
+
dependencies = [
+
"autocfg",
+
"scopeguard",
+
]
+
+
[[package]]
name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"cobs",
"embedded-io 0.4.0",
"embedded-io 0.6.1",
+
"heapless",
"serde",
]
···
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
+
name = "rustc_version"
+
version = "0.4.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+
dependencies = [
+
"semver",
+
]
+
+
[[package]]
name = "rustix"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
+
name = "semver"
+
version = "1.0.26"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
+
+
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
+
name = "spin"
+
version = "0.9.8"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+
dependencies = [
+
"lock_api",
+
]
+
+
[[package]]
name = "spki"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"base64ct",
"der",
+
+
[[package]]
+
name = "stable_deref_trait"
+
version = "1.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "strsim"
···
dependencies = [
"base58",
"hex-literal",
+
"postcard",
"serde",
"serde_ipld_dagcbor",
"vanadium-app-sdk",
···
name = "vnd-atproto-client"
version = "0.0.1"
dependencies = [
+
"postcard",
"serde_ipld_dagcbor",
"vanadium-client-sdk",
"vnd-atproto-common",
+1
Cargo.toml
···
stack_size = 65536
[dependencies]
+
postcard = { version = "1.1.1", features = ["alloc"] }
serde_ipld_dagcbor = { git = "http://github.com/edouardparis/serde_ipld_dagcbor", branch = "scopeguard-no-default-features", default-features = false }
sdk = { package = "vanadium-app-sdk", git = "https://github.com/LedgerHQ/vanadium"}
common = { package = "vnd-atproto-common", path = "common" }
+1
client/Cargo.toml
···
edition = "2021"
[dependencies]
+
postcard = { version = "1.1.1", features = ["alloc"] }
common = { package = "vnd-atproto-common", path = "../common"}
sdk = { package = "vanadium-client-sdk", git = "https://github.com/LedgerHQ/vanadium"}
serde_ipld_dagcbor = { git = "http://github.com/edouardparis/serde_ipld_dagcbor", branch = "scopeguard-no-default-features", default-features = false }
+3 -3
client/src/lib.rs
···
}
async fn parse_response(response_raw: &'a [u8]) -> Result<Response, AtprotoAppClientError> {
-
let resp: Response = serde_ipld_dagcbor::from_slice(response_raw)
+
let resp: Response = postcard::from_bytes(response_raw)
.map_err(|_| AtprotoAppClientError::GenericError("Failed to parse response"))?;
Ok(resp)
}
···
index: u32,
display: bool,
) -> Result<Vec<u8>, AtprotoAppClientError> {
-
let msg = serde_ipld_dagcbor::to_vec(&Request::GetDidKey { index, display })
+
let msg = postcard::to_allocvec(&Request::GetDidKey { index, display })
.map_err(|_| AtprotoAppClientError::GenericError("Failed to serialize Exit request"))?;
let response_raw = self.send_message(&msg).await?;
···
}
pub async fn exit(&mut self) -> Result<i32, AtprotoAppClientError> {
-
let msg = serde_ipld_dagcbor::to_vec(&Request::Exit)
+
let msg = postcard::to_allocvec(&Request::Exit)
.map_err(|_| AtprotoAppClientError::GenericError("Failed to serialize Exit request"))?;
let response_raw = self.send_message(&msg).await?;
+7 -5
src/main.rs
···
}
fn process(_app: &mut App, request: &[u8]) -> Vec<u8> {
-
let request: Request = serde_ipld_dagcbor::from_slice(request).unwrap();
+
let Ok(request) = postcard::from_bytes::<Request>(request) else {
+
return postcard::to_allocvec(&Response::Error("Invalid request".to_string())).unwrap();
+
};
let response = match request {
Request::Exit => sdk::exit(0),
-
Request::GetDidKey { index, display } => get_did_key(index, display)
-
.map_err(|e| Response::Error(e.to_string()))
-
.unwrap(),
+
Request::GetDidKey { index, display } => {
+
get_did_key(index, display).unwrap_or_else(|e| Response::Error(e.to_string()))
+
}
};
-
serde_ipld_dagcbor::to_vec(&response).unwrap()
+
postcard::to_allocvec(&response).unwrap()
}
pub fn main() {