Languages/Rust/Samples
Download Binary File/Image (Rust)
The Official Cook Book Sample Code is wrong.
Doesn't work. Instead of using .text()
, use .bytes()
and wrapped with Cursor
.
Cursor
is the main point. An experienced developer (but beginner in Rust) knows that converting binary file content to text then bytes is dangerous,
due to encoding issue; but wouldn't know about Cursor
.
Error Explained
std::io::Read
requires Read
, which Bytes
doesn't have. So Cursor
is needed.
Weird design for developer from another language.
Reference
How is this guide?