GithubHelp home page GithubHelp logo

matklad / futures-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-lang/futures-rs

0.0 3.0 0.0 4.02 MB

Zero-cost futures and streams in Rust

Home Page: http://alexcrichton.com/futures-rs

License: Apache License 2.0

Rust 100.00%

futures-rs's Introduction

futures-rs

This library is an implementation of zero cost futures in Rust.

Build Status Build status Coverage Status

Documentation

Tutorial

Usage

First, add this to your Cargo.toml:

[dependencies]
futures = { git = "https://github.com/alexcrichton/futures-rs" }

Next, add this to your crate:

extern crate futures;

use futures::Future;

And then, use futures! If this is your first time with futures in Rust, or at all, check out the tutorial.

What's using futures?

  • futures - the core abstraction of zero-cost futures
  • futures-cpupool - a thread pool for compute-bound work in event loops
  • tokio-core - a concrete implementation of TCP/UDP abstractions backed by mio composable with types implementing Future
  • tokio-proto - abstractions for easily writing new and composable protocols on top of tokio-core
  • tokio-socks5 - an implementation of an efficient SOCKSv5 proxy server showcasing futures and tokio-core
  • tokio-tls - TLS/SSL streams built on futures, implementing both client and server side connections, with support for the native system library on all platforms
  • tokio-curl - an asynchronous HTTP client backed by libcurl exposed through futures
  • tokio-uds - bindings for Unix domain sockets and futures
  • tokio-minihttp - a simple HTTP server with some "hello world" examples that show the screaming fast performance of the futures and mio stack

Why Futures?

A major missing piece of the Rust ecosystem has been how to work with Asynchronous I/O and in general composing many I/O tasks together in a lightweight way across libraries. Futures have worked out fantastically in other languages to solve this problem in frameworks like finagle and wangle, and they also turn out to be a great way to solve this problem in Rust as well!

The purpose of the futures library in this repository is to provide the foundational layer to build an ecosystem of futures-generating computations so they can all compose with one another.

The Future trait

At the heart of this crate is the Future trait, which in true Rust style, is an interface for zero allocation futures. Like iterators in Rust, there are a wide variety of helpful combinators associated with this trait which are also zero allocation and serve as a succinct and powerful way to compose computations on futures.

The Future trait is driven by one method, poll, which allows pulling values out of a future and also getting notified when a future is complete. More documentation can be found on the associated method.

More information can be found in the tutorial

I/O with futures

With the power of zero-allocation futures we can take futures all the way down the stack to the I/O layer. The tokio-core crate provides an abstraction for I/O objects as a stream of readiness notifications plus Read and Write traits along with a number of combinators you'd expect when working with std::io.

These abstractions can be implemented by the with mio to power I/O. Finally we can then use these abstractions to build a tokio-tls crate crate to provide TLS/SSL streams over arbitrary read/write streams. Finally tokio-proto can be layered on top for easily writing highly efficient protocol implementations.

License

futures-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.

futures-rs's People

Contributors

alexcrichton avatar aturon avatar killercup avatar simonsapin avatar jeandudey avatar llogiq avatar josephdunne avatar kamalmarhubi avatar stebalien avatar king6cong avatar aidanhs avatar lexxvir avatar apasel422 avatar brson avatar birkenfeld avatar sirver avatar shepmaster avatar overdrivenpotato avatar nelsonjchen avatar fitzgen avatar tmiasko avatar ghotiphud avatar ifanatic avatar pravic avatar simbiont666 avatar

Watchers

James Cloos avatar Alex Kladov avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.