smol: A small and fast async runtime for Rust
source link: https://github.com/stjepang/smol
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
smol
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
!Send
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:
- Channels, pipes, and mutexes: piper
- HTTP clients: surf , isahc , reqwest
- HTTP servers: async-h1 , hyper
- WebSockets: async-tungstenite
- TLS authentication: async-native-tls
- Signals: ctrlc , signal-hook
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
- Apache License, Version 2.0 ( LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0 )
- MIT license ( LICENSE-MIT or http://opensource.org/licenses/MIT )
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.
Recommend
-
27
-
5
Async Rust: What is a runtime? Here is how tokio works under the hood Tue, Feb 1, 2022 This post contains excerpts of my book Black Hat Rust...
-
3
Smol Dungeon How to Make Pixel Art A step-by-step guide In the design article I described the high level overview of h...
-
6
About a month ago, for some reason I got a bee in my bonnet to build a simple garbage-collected memory manager and object model. Maybe it’s because in my day job I’ve been working with a very complex one (
-
2
smol.rsvpFree and easy...
-
2
smol with John Nunley Posted Fri, 12 May 2023 15:22:00 +0000 Allen Wyma and Zeeshan Ali Khan talk with John Nunl...
-
6
Support is great. Feedback is even better."What do you think is on the brink of being possible with AI code generation for developers?"The makers of smol developerSort by:
-
8
Smol-Dev-JS You own personal AI dev, which you can direct development in a collebrative back and forth experience. Think of it as pair-programming, via the command line. Written entire in JS (no python), and is able to make both "s...
-
1
Stability AI goes ‘smol’ with StableLM Zephyr 3B
-
8
Announcing smol-macros, smol-hyper and smol-axum smol just became a much easier choice to build web servers.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK