Expand description
A lightweight library for software update.
Features:
- Lightweight
- Based on
nyquest, can use either platform-native HTTP client orreqwest. - 333 KiB on
x86_64-pc-windows-msvcwith HTTPS update checking.
- Based on
- Supported update sources:
- GitHub Releases
- Semantic Versioning handling.
- Optional pre-release update.
- Provide both sync/async APIs.
- Optional support for retrying multiple servers under unstable networks.
§Blocking API
Use UpdateConfig::builder and build_blocking.
Make sure an nyquest backend is registered before making requests:
// cargo add ib-update --features blocking
// cargo add nyquest-preset --features blocking
fn main() {
nyquest_preset::register();
let info = ib_update::github::UpdateConfig::builder()
.owner("owner")
.repo("repo")
.current_version(env!("CARGO_PKG_VERSION"))
.build_blocking()
.check()
.expect("failed to check for updates");
if info.has_update() {
println!("New version {} is available!", info.latest().tag);
}
}§Async API
Use UpdateConfig::builder and build_async.
Make sure an nyquest backend is registered before making requests:
// cargo add ib-update --features async
// cargo add nyquest-preset --features blocking
fn main() {
nyquest_preset::register();
futures::executor::block_on(async {
let info = ib_update::github::UpdateConfig::builder()
.owner("owner")
.repo("repo")
.current_version(env!("CARGO_PKG_VERSION"))
.build_async()
.check()
.await
.expect("failed to check for updates");
if info.has_update() {
println!("New version {} is available!", info.latest().tag);
}
});
}§Binary size
The following Cargo.toml settings are recommended if small binary size is desired:
[profile.release]
lto = "fat"
codegen-units = 1
strip = trueThese can reduce the size by ~50 KiB on x86_64-pc-windows-msvc.
§Crate features
-
async— Async HTTP client. -
blocking— Blocking HTTP client. -
multi-server— Support retrying multiple servers under unstable networks.Binary size +~3.5 KiB (2.5/4.5 KiB).
-
github-extra— GitHub Releases update source extra features.These features are usually not used but will raise binary size by ~4 KiB (3/4.5 KiB). Include custom URL, UA, token, release asset
download_count.
Re-exports§
pub use semver;
Modules§
- github
- GitHub Releases update source.