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 init2
Create a new directory automatically:
cargo new my_bot3
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
[package]
name = "axum_api"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.7"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
dotenvy = "0.15"Must listen on 0.0.0.0:8080.
Requires nightly toolchain + bind to port 8080.
🧰 Common Commands Reference
Optional tools:
Last updated