Cargo.toml

Comprehensive guide to the Cargo.toml manifest for Rust bots and web (site/API) apps on Discloud.

🗂️ What is Cargo.toml?

Cargo.toml is the manifest that defines your Rust package (crate) metadata: name, version, authors, edition, dependencies, features, build scripts and more. Discloud relies on it to resolve and compile your project before starting it.


🛠️ Creating a New Project

1

Initialize in existing directory:

cargo init
2

Create a new directory automatically:

cargo new my_bot

Use snake_case or kebab-case names.

3

Add a dependency quickly (Cargo 1.62+):

cargo add serenity

Need Rust? See the installation page.


📦 Examples

Cargo.toml
[package]
name = "discord_bot"
version = "0.1.0"
edition = "2021"

[dependencies]
serenity = { version = "0.11", default-features = false, features = [
	"client", "gateway", "rustls_backend", "model" ] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tracing = "0.1"
dotenvy = "0.15"

Serenity is a Discord API library: https://crates.io/crates/serenity

Need OS-level dependencies (e.g. openssl, ffmpeg)? Add them under APT= in discloud.config. See the APT packages list for syntax and examples.


🧰 Common Commands Reference

# Build debug
cargo build

# Build release
cargo build --release

# Run
cargo run

# Add dependency
cargo add <crate>

# Remove dependency
cargo rm <crate>

# Audit (optional; needs cargo-audit)
cargo audit

Optional tools:

cargo install cargo-edit cargo-outdated cargo-audit

Last updated