Using the Future trait
Future is a trait that returns a result in the future and represents an operation that can't be completed immediately. Like the Result enumeration, Future has two outcome variants that are represented by the associated types Item and Error. The trait has a poll method, which is what retrieves the result. This method will be called by a reactor until it returns Error or an Async::Ready value. Async is an enumeration that has both Ready and Pending variants, which are used to represent a result of an asynchronous operation. Ready means the value is ready to use, while Pending means the value is not yet available and will be ready later.
As you can see, Future is used for a similar purpose to Result. Unlike Result, however, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access