You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After you read the length with read_bin_len, I think all you have to do is reading the data directly from your data input.
For example, assuming you read from some impl std::io::Read:
fnread_bin_to_vec(r:implRead) -> Result<Vec<u8>>{// First read the length of the following bin datalet len = rmp::decode::read_bin_len(&mut r)? asusize;// Then allocate a vec with the read length and// read the data into itletmut buf = vec![0; len];
r.read_exact(&mut buf)?;Ok(buf)}
I guess the reason for the missingread_bin is, that there are simply many ways of reading raw data, depending on your data input and the place you want to put the data.
Maybe you want to read into a fresh Vec<u8>, but maybe instead you just want to take a slice out of your input (in case of an already read vector with the raw msgpack data). Or maybe even directly write the bin data out into a file, and, and, and ...
I'm creating a low-level, codec used by multiple languages using MsgPack.
RMP has this
encode
API:However, it has this
decode
API:I was expecting a symmetric
rmp::decode::read_bin(...)
.What's the idiomatic way to read raw bytes using the API?
The text was updated successfully, but these errors were encountered: