Using Rust
ServBay offers developers an easy-to-use toolchain for Rust development on macOS. Through ServBay's package management system, you can effortlessly install and manage the Rust environment, including the rustc
compiler and the build system and package manager cargo
.
Overview
Introduction to the Rust Language
Rust is a modern systems programming language focused on performance, memory safety, and concurrency. Originally designed by Graydon Hoare at Mozilla Research and first released publicly in 2010, its 1.0 stable version launched in 2015. Rust aims to provide C++-level performance and control, while guaranteeing memory safety at compile time through its innovative ownership and borrowing system. This design avoids common C/C++ pitfalls like null pointers, dangling pointers, and data races— and all without a garbage collector.
Thanks to its safety features, speed, and robust concurrency capabilities, Rust has quickly gained popularity in the developer community. It’s been ranked as the “most loved programming language” in Stack Overflow's annual developer survey for years. Rust is widely used in systems development, web backend services (such as Actix Web, Rocket), WebAssembly, command-line tools, game engines, embedded systems, and more.
ServBay's Support for Rust
ServBay manages the Rust toolchain as a standalone package. This means:
- Simplified Installation: No need to manually download installers or use
rustup
for complex setup. Install with a single click from ServBay's graphical interface. - Environment Integration: After installation, both
rustc
andcargo
commands are automatically available in the ServBay-managed terminal environment. - Unified Management: Manage Rust alongside other programming languages, databases, and tools all within the unified ServBay interface.
This provides an accessible starting point for developers working in systems programming, WebAssembly, high-performance web services, or any other Rust-based applications.
Accessing the Rust Package
- Open the ServBay application.
- In the left sidebar, click on
Packages
. - On the
Packages
page, scroll down or selectLanguages
->Rust
from the sidebar sublist. - The right panel will display available Rust packages. ServBay typically offers a stable version of the Rust toolchain.
Installing Rust
The package list shows the status of the Rust toolchain:
- Package Name: For example,
Rust
. - Version: The included Rust toolchain version (e.g., 1.86.0).
- Status: Shows
Installed
orNot Installed
. - Control: Provides action buttons.
To install the Rust toolchain:
- Make sure the status is
Not Installed
. - Click the Download/Install icon (typically a downward arrow) on the far right.
- ServBay will begin downloading and installing Rust.
- Once installation is complete, the status will update to
Installed
and the control icon will change to the Uninstall icon (trash can).
Managing Installed Rust
- View Installed Version: Confirm your current Rust version by looking for the
Installed
status and the version number in the list. - Uninstall Rust: If you no longer need the Rust environment managed by ServBay, just click its Uninstall icon (trash can) and confirm.
Using Rust (Cargo & rustc)
Once installed, you can use the cargo
and rustc
commands in a terminal activated under the ServBay environment.
Common Command Examples:
Check Rust compiler version:
bashrustc --version
1Check Cargo version:
bashcargo --version
1Create a new Rust project (using Cargo): Cargo is Rust’s official build tool and package manager. It’s recommended for creating and managing projects.
bash# Create a new binary project named hello_servbay cargo new hello_servbay --bin cd hello_servbay
1
2
3This creates a standard project structure:
Cargo.toml
: Project configuration file (metadata, dependencies, etc.).src/main.rs
: The entry point source file for the project.
View
src/main.rs
(default content):rustfn main() { println!("Hello, world!"); }
1
2
3Build and run the project:
bash# Cargo compiles your code, produces an executable in target/debug, and runs it cargo run
1
2You should see the terminal output:
Hello, world!
Build the project (debug mode only):
bashcargo build
1The executable will be at
./target/debug/hello_servbay
.Build the project (release/optimized mode):
bashcargo build --release
1The optimized executable will be at
./target/release/hello_servbay
.Add dependencies: Edit the
Cargo.toml
file and add the libraries you need (called "crates") under the[dependencies]
section, e.g. to add the popular web frameworkactix-web
:toml[dependencies] actix-web = "4" # Specify the version requirement
1
2Then run
cargo build
orcargo run
and Cargo will automatically download and compile the dependencies.
Integrating a Web Server (Deploying Rust Web Apps)
Rust-powered web applications (using frameworks such as Actix Web, Rocket, Axum, Tokio, etc.) are usually compiled into standalone, high-performance executables.
You can run the compiled binary directly in your terminal. To allow access via standard ports (80/443) and leverage ServBay’s domain management and SSL capabilities, it’s recommended to:
- Create a Website in ServBay for your Rust web application.
- Configure ServBay’s web server (Nginx, Caddy, or Apache) as a reverse proxy to forward incoming requests from your website’s domain to the internal port your Rust app is listening on (e.g.,
http://127.0.0.1:8080
).
Summary
By providing easy-to-install and manage Rust packages, ServBay lowers the barrier to starting Rust development on macOS. You get access to the core rustc
compiler and the powerful cargo
build tool, so you can focus on writing high-performance, reliable Rust code. Combined with ServBay’s reverse proxy features, deploying local Rust web services becomes even more convenient.