serde_cbor::from_slice::<$ser>(&de[..]).wrap_err(eyre!("Failed to deserialise {} from reader",std::any::type_name::<$ser>()))
})?
}
};
($into:expr,$num:expr)=>{
{
letnum=$num;
letreader=(&mutbytes).reader();
copy_buffer($into,reader,num).wrap_err(eyre!("Failed to read {} bytes from reader",num))?
}
}
}
letheader=read!(: SerHeader);
letdata_len=usize::try_from(bytes.get_u64())?;
letmutdata=Vec::with_capacity(std::cmp::min(data_len,MAX_ALLOC_SIZE));//XXX: Redesign so we don't allocate OR try to read massive buffers by accident on corrupted/malformed messages
read!(&mutdata,data_len);
ifdata.len()!=data_len{
returnErr(eyre!("Failed to read {} bytes from buffer (got {})",data_len,data.len()));