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
?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
3
Add a dependency quickly (Cargo 1.62+):
cargo add serenity
📦 Examples
[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
🧰 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