reqwless-linux#
A demonstration of a no_std reqwless http downloader for linux
Usage#
cargo run -- http://example.com
This prints the HTTP response body to stdout.
To enable baseline HTTPS support:
cargo run --features https -- https://example.com
Notes#
no_std+no_mainbinary using Linux libc syscalls- Uses
reqwlesswithdefault-features = false - Default feature set is
backend-posix-libc+dns-getaddrinfo backend-rustixis available as an alternate transport backend- DNS mode is selected independently via
dns-getaddrinfoordns-ip-only - Alternate DNS mode
dns-ip-onlyrejects hostnames and only accepts literal IP hosts - HTTPS is optional via
--features httpsand requires an RNG backend - HTTPS currently uses
TlsVerify::None(insecure baseline) - RNG backends:
rng-dummy(fixed seed),rng-dev-urandom(reads/dev/urandom),rng-getrandom(syscall) - Uses fixed-size stack buffers for request/response and output chunks
- Performs best-effort low-allocation operation (no
String/Vecin app code)
Feature examples#
# Default build: posix-libc backend + getaddrinfo DNS mode
cargo run -- http://example.com
# HTTPS with dev-urandom RNG (recommended for production)
cargo run --no-default-features --features backend-posix-libc,dns-getaddrinfo,https,rng-dev-urandom -- https://example.com
# HTTPS with getrandom syscall RNG
cargo run --no-default-features --features backend-posix-libc,dns-getaddrinfo,https,rng-getrandom -- https://example.com
# HTTPS with dummy RNG (testing only, insecure)
cargo run --no-default-features --features backend-posix-libc,dns-getaddrinfo,https,rng-dummy -- https://example.com
# Minimal DNS mode (literal IP hosts only)
cargo run --no-default-features --features backend-posix-libc,dns-ip-only -- http://93.184.216.34
# Rustix backend with getaddrinfo DNS mode
cargo run --no-default-features --features backend-rustix,dns-getaddrinfo -- http://example.com
# Rustix backend with IP-only DNS mode
cargo run --no-default-features --features backend-rustix,dns-ip-only -- http://93.184.216.34
Validation#
Use the composite xtask validation flow for reproducible checks.
cargo run -p xtask -- validate
The xtask validate subcommand group is self-documented in CLI help and can be explored as needed.
Benchmarking#
To benchmark RNG backends with hyperfine:
# Install hyperfine first
cargo install hyperfine
# Run benchmarks
cargo run -p xtask -- benchmark
This builds three binaries with different RNG backends and compares their performance:
rng-dummy: ~0.3 ns (constant, no actual randomness)rng-dev-urandom: ~1.2 μs (file I/O)rng-getrandom: ~0.24 μs (syscall, 5x faster)
Manual benchmark:
cargo run --release --bin bench-rng --no-default-features --features rng-getrandom -- 10000
Binary size comparison#
Release builds are tuned for binary size in Cargo.toml:
panic = "abort"strip = trueopt-level = "s"lto = truecodegen-units = 1
Nightly aggressive builds use additional optimizations:
RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none -Zunstable-options -Cpanic=immediate-abort"-Z build-std=std,panic_abort-Z build-std-features=
HTTP builds#
| Backend | DNS | Release | Nightly | Savings |
|---|---|---|---|---|
| posix-libc | getaddrinfo | 43,440 B | 41,288 B | -2,152 B (-5.0%) |
| posix-libc | dns-ip-only | 43,952 B | 41,864 B | -2,088 B (-4.8%) |
| rustix | getaddrinfo | 43,512 B | 41,104 B | -2,408 B (-5.5%) |
| rustix | dns-ip-only | 43,784 B | 41,792 B | -1,992 B (-4.5%) |
HTTPS builds#
| Backend | DNS | RNG | Release | Nightly | Savings |
|---|---|---|---|---|---|
| posix-libc | getaddrinfo | dummy | 296,824 B | 296,112 B | -712 B (-0.2%) |
| posix-libc | getaddrinfo | dev-urandom | 297,192 B | 296,584 B | -608 B (-0.2%) |
| posix-libc | getaddrinfo | getrandom | 297,072 B | 296,464 B | -608 B (-0.2%) |
| posix-libc | dns-ip-only | dummy | 297,304 B | 296,832 B | -472 B (-0.2%) |
| posix-libc | dns-ip-only | dev-urandom | 297,688 B | 297,224 B | -464 B (-0.2%) |
| posix-libc | dns-ip-only | getrandom | 297,552 B | 297,168 B | -384 B (-0.1%) |
| rustix | getaddrinfo | dummy | 296,592 B | 295,768 B | -824 B (-0.3%) |
| rustix | getaddrinfo | dev-urandom | 297,000 B | 296,312 B | -688 B (-0.2%) |
| rustix | getaddrinfo | getrandom | 296,824 B | 296,120 B | -704 B (-0.2%) |
| rustix | dns-ip-only | dummy | 297,344 B | 296,600 B | -744 B (-0.3%) |
| rustix | dns-ip-only | dev-urandom | 297,800 B | 297,048 B | -752 B (-0.3%) |
| rustix | dns-ip-only | getrandom | 297,592 B | 296,920 B | -672 B (-0.2%) |
Building for size#
For standard release builds:
cargo build --release --no-default-features --features <features>
For nightly aggressive size optimizations:
cargo run -p xtask -- nightly-size -- --no-default-features --features <features>