Hello World in Rust
Create your first WendyOS application using Rust
Creating Your First Rust Application
This guide will walk you through creating a simple "Hello, World!" application for WendyOS using Rust. This is a great way to prove that you can send your first app to your device and verify your development environment is set up correctly.
Prerequisites
- Wendy CLI installed on your development machine
- Rust 1.83 or later installed (via
rustup) - A WendyOS device plugged in over USB or connectable over Wi-Fi
Containerized Deployment: Unlike Swift, which compiles natively for WendyOS, Rust applications run inside containers on your WendyOS device. The Wendy CLI handles the local build setup when deploying Rust applications.
Creating the Project
Initialize the Project
Start from the Wendy Rust template:
wendy init hello-world --target wendyos --language rust --template simple-api --var APP_ID=hello-world --var PORT=4001 --assistant skip --git-init no
cd hello-worldThe template creates Cargo.toml, src/main.rs, Dockerfile, and wendy.json. Continue below to understand the generated project.
Run on WendyOS
wendy runWendy will build the app, ask you to select a device if one is not already configured, deploy the app, and show the run output.
Code Breakdown
Explore the Project Structure
The initialized project has this structure:
hello-world/
├── Cargo.toml
└── src/
└── main.rsThe main application code is in src/main.rs.
Verify the Code
The generated src/main.rs file should contain:
fn main() {
println!("Hello, world!");
}This is the entry point for your WendyOS application.
Verify Cargo.toml
Your Cargo.toml should look like:
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
[dependencies]Generated Dockerfile
The generated project includes a Dockerfile for containerized deployment:
# Build stage
FROM rust:1.83-slim AS builder
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/hello-world /usr/local/bin/hello-world
CMD ["hello-world"]Run Again on WendyOS
Deploy your containerized application to your WendyOS device:
wendy runThe Wendy CLI will build your Docker image, transfer it to your device, and run it.
Verifying Deployment on Your Device
After deploying your application to a WendyOS device, you can verify it was successfully deployed and ran by listing the applications on your device:
wendy device apps list
✔︎ Searching for WendyOS devices [5.3s]
✔︎ Listing applications: True Probe [USB, Ethernet, LAN]
╭───────────────┬─────────┬─────────┬──────────╮
│ App │ Version │ State │ Failures │
├───────────────┼─────────┼─────────┼──────────┤
│ hello-world │ 0.0.1 │ Stopped │ 0 │
╰───────────────┴─────────┴─────────┴──────────╯Expected State: The app shows as "Stopped" because a hello-world application exits immediately after printing its message. This is expected behavior. The key indicator of success is the "Failures" column showing 0, which confirms your application ran and exited successfully without any errors.
Next Steps
Now that you have a basic Rust application running:
- Learn how to build a Simple Web Server with Axum
- Explore environment variables and configuration
- Build more complex applications with networking and data processing
- Integrate with WendyOS device features via HTTP APIs
Containerized Deployment: Rust applications on WendyOS run in containers. This provides isolation and portability while the Wendy CLI manages the deployment workflow.