pub type BincodeLen<const PREALLOCATION_SIZE_LIMIT: usize = PREALLOCATION_SIZE_LIMIT_USE_CONFIG> = UseIntLen<u64, PREALLOCATION_SIZE_LIMIT>;Expand description
Bincode always uses a u64 encoded with the configuration’s integer encoding.
Allows overriding the preallocation size limit per individual use.
§Examples
Override the preallocation size limit to 8 bytes.
type Max8Bytes = BincodeLen<8>;
#[derive(SchemaWrite, SchemaRead)]
struct OverrideLen {
#[wincode(with = "containers::Vec<u8, Max8Bytes>")]
bytes: Vec<u8>,
}
let data_ok = OverrideLen { bytes: vec![0; 8] };
let serialized = wincode::serialize(&data_ok).unwrap();
assert!(wincode::deserialize::<OverrideLen>(&serialized).is_ok());
let data_err = OverrideLen { bytes: vec![0; 9] };
assert!(wincode::serialize(&data_err).is_err());
let serialized = wincode::serialize(&vec![0; 9]).unwrap();
assert!(wincode::deserialize::<OverrideLen>(&serialized).is_err());Aliased Type§
pub struct BincodeLen<const PREALLOCATION_SIZE_LIMIT: usize = PREALLOCATION_SIZE_LIMIT_USE_CONFIG>(/* private fields */);