• Stars
    star
    2,871
  • Rank 15,147 (Top 0.4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small and fast async runtime for Rust

smol

Build License Cargo Documentation Chat

kitty

A small and fast async runtime.

This crate simply re-exports other smaller async crates (see the source).

To use tokio-based libraries with smol, apply the async-compat adapter to futures and I/O types.

Examples

Connect to an HTTP website, make a GET request, and pipe the response to the standard output:

use smol::{io, net, prelude::*, Unblock};

fn main() -> io::Result<()> {
    smol::block_on(async {
        let mut stream = net::TcpStream::connect("example.com:80").await?;
        let req = b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n";
        stream.write_all(req).await?;

        let mut stdout = Unblock::new(std::io::stdout());
        io::copy(stream, &mut stdout).await?;
        Ok(())
    })
}

There's a lot more in the examples directory.

Subcrates

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

Another useful tool for making certificates is mkcert.

MSRV Policy

The Minimum Supported Rust Version (MSRV) of this crate is 1.63. As a tentative policy, the MSRV will not advance past the current Rust version provided by Debian Stable. At the time of writing, this version of Rust is 1.63. However, the MSRV may be advanced further in the event of a major ecosystem shift or a security vulnerability.

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.

More Repositories

1

async-channel

Async multi-producer multi-consumer channel
Rust
524
star
2

async-io

Async I/O and timers
Rust
330
star
3

polling

Portable interface to epoll, kqueue, event ports, and wepoll
Rust
329
star
4

futures-lite

Futures, streams, and async I/O combinators.
Rust
293
star
5

fastrand

A simple and fast random number generator
Rust
287
star
6

blocking

A thread pool for isolating blocking I/O in async programs
Rust
278
star
7

event-listener

Notify async tasks or threads
Rust
274
star
8

async-task

Task abstraction for building executors
Rust
255
star
9

async-lock

Async synchronization primitives
Rust
193
star
10

concurrent-queue

Concurrent multi-producer multi-consumer queue
Rust
180
star
11

async-executor

Async executor
Rust
179
star
12

async-process

Async interface for working with processes
Rust
124
star
13

async-compat

Compatibility adapter between tokio and futures
Rust
120
star
14

async-net

Async networking primitives for TCP/UDP/Unix communication
Rust
112
star
15

async-fs

Async filesystem primitives
Rust
110
star
16

easy-parallel

Run closures in parallel
Rust
100
star
17

async-broadcast

Async broadcast channels
Rust
96
star
18

parking

Thread parking and unparking
Rust
55
star
19

cache-padded

Prevent false sharing by padding and aligning to the length of a cache line
Rust
50
star
20

waker-fn

Convert closures into wakers
Rust
38
star
21

vec-arena

[DEPRECATED] A simple object arena
Rust
38
star
22

async-rustls

Async TLS/SSL streams using rustls
Rust
32
star
23

async-dup

Duplicate an async I/O handle
Rust
31
star
24

atomic-waker

futures::task::AtomicWaker extracted into its own crate
Rust
18
star
25

nb-connect

[DEPRECATED] Non-blocking TCP or Unix connect
Rust
15
star
26

piper

An asynchronous single-consumer single-producer pipe for bytes
Rust
6
star
27

fastrand-contrib

Extension functionality for the fastrand crate
Rust
3
star
28

async-signal

Asynchronous signal handling
Rust
3
star
29

smol-macros

Macros for using smol-rs
Rust
1
star