1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*!
A lightweight library for software update.
Features:
- Lightweight
- Based on [`nyquest`](https://github.com/bdbai/nyquest),
can use either platform-native HTTP client or `reqwest`.
- 333 KiB on `x86_64-pc-windows-msvc` with HTTPS update checking.
- Supported update sources:
- GitHub Releases
- [Semantic Versioning](https://semver.org) handling.
- Optional pre-release update.
- Provide both sync/async APIs.
- Optional support for retrying multiple servers under unstable networks.
## Blocking API
Use [`UpdateConfig::builder`](github::UpdateConfig::builder) and [`build_blocking`](github::UpdateConfigBuilder::build_blocking).
Make sure an nyquest backend is registered before making requests:
```no_run
// 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`](github::UpdateConfig::builder) and [`build_async`](github::UpdateConfigBuilder::build_async).
Make sure an nyquest backend is registered before making requests:
```no_run
// 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:
```toml
[profile.release]
lto = "fat"
codegen-units = 1
strip = true
```
These can reduce the size by ~50 KiB on `x86_64-pc-windows-msvc`.
## Crate features
*/
/// Re-export of the `semver` crate for users who want to construct or compare
/// version strings independently.
pub use semver;