Skip to content

Commit b70af35

Browse files
committed
Updating Rust getting started
1 parent df8fe32 commit b70af35

File tree

2 files changed

+85
-55
lines changed

2 files changed

+85
-55
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Install Velopack cargo crate</strong>
5+
</summary>
6+
7+
Add Velopack to your `Cargo.toml`:
8+
```toml
9+
[dependencies]
10+
velopack = { version = "0.0", features = ["async"] } # Replace with actual version and desired features
11+
```
12+
</details>
13+
</FancyStep>

docs/getting-started/rust.mdx

Lines changed: 72 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,80 @@
1+
import InstallCargo from './content/_install-cargo.mdx';
2+
import InstallVpk from './content/_install-vpk.mdx';
3+
import BuildRelease from './content/_build-release.mdx';
4+
import Completion from './content/_completion.mdx';
5+
16
# Getting Started: Rust
27
<AppliesTo all />
38
Get started with our official cross-platform Rust crate.
49

510
:::tip
611
To find the most accurate and complete documentation for Rust please visit https://docs.rs/velopack
712
:::
13+
14+
815
## Quick Start
9-
1. Add Velopack to your `Cargo.toml`:
10-
```toml
11-
[dependencies]
12-
velopack = { version = "0.0", features = ["async"] } # Replace with actual version and desired features
13-
```
14-
15-
2. Add the following code to your `main()` function:
16-
```rust
17-
use velopack::*;
18-
19-
fn main() {
20-
// VelopackApp should be the first thing to run, in some circumstances it may terminate/restart the process to perform tasks.
21-
VelopackApp::build().run();
22-
// Your other app startup code here
23-
}
24-
```
25-
26-
3. Add auto-updates somewhere to your app:
27-
```rust
28-
use velopack::*;
29-
30-
fn update_my_app() {
31-
let source = sources::HttpSource::new("https://the.place/you-host/updates");
32-
let um = UpdateManager::new(source, None, None).unwrap();
33-
34-
if let UpdateCheck::UpdateAvailable(updates) = um.check_for_updates().unwrap() {
35-
// there was an update available. Download it.
36-
um.download_updates(&updates, None).unwrap();
37-
38-
// download completed, let's restart and update
39-
um.apply_updates_and_restart(&updates).unwrap();
40-
}
41-
}
42-
```
43-
44-
4. Build your app with cargo:
45-
```sh
46-
cargo build --release
47-
```
48-
49-
5. Install the `vpk` command line tool:
50-
```sh
51-
dotnet tool update -g vpk
52-
```
53-
***Note: you must have the .NET Core SDK 8 installed to use and update `vpk`***
54-
55-
6. Package your Velopack release / installers:
56-
```sh
57-
vpk pack -u MyAppUniqueId -v 1.0.0 -p /target/release -e myexename.exe
58-
```
59-
60-
✅ You're Done! Your app now has auto-updates and an installer.
61-
You can upload your release to your website, or use the `vpk upload` command to publish it to the destination of your choice.
62-
63-
Read the Velopack documentation at [https://docs.velopack.io/](https://docs.velopack.io/) for more information.
16+
<InstallCargo step={1}/>
17+
18+
<FancyStep step={2}>
19+
<details>
20+
<summary>
21+
<strong>Configure Velopack at the beginning of main</strong>
22+
</summary>
23+
24+
Add the following code to your `main()` function:
25+
```rust
26+
use velopack::*;
27+
28+
fn main() {
29+
// VelopackApp should be the first thing to run, in some circumstances it may terminate/restart the process to perform tasks.
30+
VelopackApp::build().run();
31+
// Your other app startup code here
32+
}
33+
```
34+
</details>
35+
</FancyStep>
36+
37+
<FancyStep step={3}>
38+
<details>
39+
<summary>
40+
<strong>Add update check within your app</strong>
41+
</summary>
42+
43+
Add auto-updates somewhere to your app:
44+
```rust
45+
use velopack::*;
46+
47+
fn update_my_app() {
48+
let source = sources::HttpSource::new("https://the.place/you-host/updates");
49+
let um = UpdateManager::new(source, None, None).unwrap();
50+
51+
if let UpdateCheck::UpdateAvailable(updates) = um.check_for_updates().unwrap() {
52+
// there was an update available. Download it.
53+
um.download_updates(&updates, None).unwrap();
54+
55+
// download completed, let's restart and update
56+
um.apply_updates_and_restart(&updates).unwrap();
57+
}
58+
}
59+
```
60+
</details>
61+
</FancyStep>
62+
63+
<FancyStep step={4}>
64+
<details>
65+
<summary>
66+
<strong>Build your app</strong>
67+
</summary>
68+
69+
Build your app with cargo:
70+
```sh
71+
cargo build --release
72+
```
73+
</details>
74+
</FancyStep>
75+
76+
<InstallVpk step={5}/>
77+
78+
<BuildRelease step={6}/>
79+
80+
<Completion />

0 commit comments

Comments
 (0)