Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Network Programming with Rust

You're reading from   Network Programming with Rust Build fast and resilient network servers and clients by leveraging Rust's memory-safety and concurrency features

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788624893
Length 278 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Abhishek Chanda Abhishek Chanda
Author Profile Icon Abhishek Chanda
Abhishek Chanda
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Looking into the Future

The backbone of Rust's asynchronous programming story is the futures crate. This crate provides a construct called a future. This is essentially a placeholder for the result of an operation. As you would expect, the result of an operation can be in one of two states—either the operation is still in progress and the result is not available yet, or the operation has finished and the result is available. Note that in the second case, there might have been an error, making the result immaterial.

The library provides a trait called Future (among other things),which any type can implement to be able to act like a future. This is how the trait looks:

trait Future {
type Item;
type Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error>;
...
}

Here, Item refers to the type of the returned result on successful completion of...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image