January 2019
Intermediate to advanced
520 pages
14h 32m
English
We now have to create a chain to read all incoming chunks and write them to the created file. As you might remember, File::create returns a Future that returns a File instance. We won't take the result immediately, because I/O operations take some time and can cause the current running thread to be blocked. We have to use the Future::and_then method to move the result (when it is ready) to other Future instance that will send all chunks to the file. To do that, we will use a Body instance that we get with the into_body method call of the Request that is stored in the req variable. The Body implements a Stream of the Chunk instances, but it can produce a hyper::Error. Since File::create can produce an io::Error ...
Read now
Unlock full access