tiny-update-check
A minimal, lightweight crate update checker for Rust CLI applications.
Why?
Existing update checker crates add significant binary bloat:
| Crate | Binary Impact |
|---|---|
| tiny-update-check | ~0.5MB |
| update-informer | ~1.4MB |
| updates | ~1.8MB |
This crate achieves minimal size by:
- Using
native-tls(system TLS) instead of bundling rustls - Minimal JSON parsing (string search instead of serde)
- Simple file-based caching
Installation
[]
= "1"
For pure-Rust TLS (larger binary, but better cross-compilation):
[]
= { = "1", = false, = ["rustls"] }
Usage
Simple
use check;
With Configuration
use UpdateChecker;
use Duration;
Disable Caching
use UpdateChecker;
use Duration;
let checker = new
.cache_duration; // Always fetch fresh
Custom Cache Directory
use UpdateChecker;
use PathBuf;
// Use a custom cache directory
let checker = new
.cache_dir;
// Or disable caching entirely
let checker = new
.cache_dir;
Pre-release Versions
By default, pre-release versions (e.g., 2.0.0-alpha.1) are excluded from update
checks. Opt in to receive pre-release notifications:
use UpdateChecker;
let checker = new
.include_prerelease;
Async Usage
Enable the async feature for async applications:
[]
= { = "1", = ["async"] }
= { = "1", = ["rt-multi-thread", "macros"] }
use r#UpdateChecker;
async
Features
| Feature | Default | Description |
|---|---|---|
native-tls |
✅ | Uses system TLS libraries, smaller binary |
do-not-track |
✅ | Respects the DO_NOT_TRACK environment variable |
rustls |
Pure Rust TLS, no system dependencies | |
async |
Async support using reqwest |
|
response-body |
Includes the raw crates.io response body in UpdateInfo |
Update Messages
You can attach a message to update notifications by hosting a plain text file at a URL:
use UpdateChecker;
let checker = new
.message_url;
if let Ok = checker.check
The message is fetched only when an update is available. If the fetch fails, the
update check still succeeds with message set to None.
Raw Response Body
Enable the response-body feature to access the full crates.io API response:
[]
= { = "1", = ["response-body"] }
This adds a response_body: Option<String> field to UpdateInfo, letting you
extract any field from the crates.io response using your own parsing logic.
Error Handling
The Error enum covers all failure modes:
| Variant | Cause |
|---|---|
HttpError |
Network or HTTP request failure |
ParseError |
Failed to parse crates.io response JSON |
VersionError |
Invalid semver version string |
CacheError |
Cache file I/O failure |
InvalidCrateName |
Crate name fails validation (empty, too long, invalid characters) |
Update checks are designed to fail gracefully — errors should typically be logged and ignored so they don't disrupt the user's workflow.
How It Works
- Checks cache file (in platform cache directory) for recent version info
- If cache is stale (default: 24 hours), queries crates.io API
- Compares versions using semver
- Returns
Some(UpdateInfo)if newer version exists
Cache locations by platform:
- Linux:
$XDG_CACHE_HOME/<crate>-update-checkor$HOME/.cache/<crate>-update-check - macOS:
$HOME/Library/Caches/<crate>-update-check - Windows:
%LOCALAPPDATA%\<crate>-update-check
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.