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
I've got a use case where I would like to efficiently serialize something like
Vec<Option<TxOut>>and I can't usebitcoin::consensus::serializebecauseOptionit's notEncodableand it looks neither I can use serde because it's not efficient at all (maybe because it's json specific?).maybe related rust-bitcoin/rust-secp256k1#295
UPDATED: changed
serde_cbor::to_vectoserde_cbor::ser::to_vec_packedbecause I noticedto_vecstore also field names which is unfair compared to others