-
Notifications
You must be signed in to change notification settings - Fork 965
Efficiently serialize non Encodable data #595
Copy link
Copy link
Closed
Description
I've got a use case where I would like to efficiently serialize something like Vec<Option<TxOut>> and I can't use bitcoin::consensus::serialize because Option it's not Encodable and it looks neither I can use serde because it's not efficient at all (maybe because it's json specific?).
let genesis = genesis_block(Network::Bitcoin);
let a = serde_cbor::ser::to_vec_packed(&genesis).unwrap();
assert_eq!(461, a.len());
let b= bitcoin::consensus::serialize(&genesis);
assert_eq!(285, b.len());
let c: Vec<u8> = bincode::serialize(&genesis).unwrap();
assert_eq!(496, c.len());
maybe related rust-bitcoin/rust-secp256k1#295
UPDATED: changed serde_cbor::to_vec to serde_cbor::ser::to_vec_packed because I noticed to_vec store also field names which is unfair compared to others
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels