Code Monkey home page Code Monkey logo

smol's Introduction

smol

Build Coverage Status License Cargo Documentation Chat

A small and fast async runtime for Rust.

This runtime extends the standard library with async combinators and is only 1500 lines of code long.

Reading the docs or looking at the examples is a great way to start learning async Rust.

Async I/O is implemented using epoll on Linux/Android, kqueue on macOS/iOS/BSD, and wepoll on Windows.

What makes smol different from async-std and tokio? Read this blog post.

Features

  • Async TCP, UDP, Unix domain sockets, and custom file descriptors.
  • Thread-local executor for !Send futures.
  • Work-stealing executor that adapts to uneven workloads.
  • Blocking executor for files, processes, and standard I/O.
  • Tasks that support cancelation.
  • Userspace timers.

Examples

You need to be in the examples directory to run them:

$ cd examples
$ ls
$ cargo run --example ctrl-c

Compatibility

See this example for how to use smol with async-std, tokio, surf, and reqwest.

There is an optional feature for seamless integration with crates depending on tokio. It creates a global tokio runtime and sets up its context inside smol. Enable the feature as follows:

[dependencies]
smol = { version = "0.1", features = ["tokio02"] }

Documentation

You can read the docs here, or generate them on your own.

If you'd like to explore the implementation in more depth, the following command generates docs for the whole crate, including private modules:

cargo doc --document-private-items --no-deps --open

Other crates

My personal crate recommendation list:

TLS certificate

Some code examples are using TLS for authentication. The repository contains a self-signed certificate usable for testing, but it should not be used for real-world scenarios. Browsers and tools like curl will show this certificate as insecure.

In browsers, accept the security prompt or use curl -k on the command line to bypass security warnings.

The certificate file was generated using minica and openssl:

minica --domains localhost -ip-addresses 127.0.0.1 -ca-cert certificate.pem
openssl pkcs12 -export -out identity.pfx -inkey localhost/key.pem -in localhost/cert.pem

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

smol's People

Contributors

0x7cfe avatar akhilles avatar alexeldeib avatar byron avatar creativcoder avatar dignifiedquire avatar hwchen avatar irevoire avatar jadireddi avatar joshtriplett avatar k-nasa avatar llebout avatar matklad avatar plecra avatar polachok avatar rahul-ather avatar svartalf avatar taiki-e avatar tshepang avatar windsoilder avatar wolf4ood avatar

Watchers

 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.