Skip to content

Rust Crates — Publishing and Using Crates from crates.io and Private Registries

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you will learn about Rust Crates. We cover key concepts, practical examples, and best practices to help you master this topic.

Rust crates from crates.io provide reusable libraries with Cargo dependency resolution, semver versioning, and publishing workflows.

What You'll Learn

  • Finding and using crates
  • Creating a library crate
  • Publishing to crates.io
  • Private registries

Why It Matters

Crates enable code reuse. DodaZIP uses serde, tokio, and zip crates. The Rust ecosystem has 150,000+ crates.

Real-World Use

Serialization, async runtime, HTTP clients, database drivers, CLI frameworks.

# Cargo.toml
[package]
name = "my_utility"
version = "0.1.0"
edition = "2021"
description = "A useful utility crate"
license = "MIT"
repository = "https://github.com/user/my_utility"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
//! # My Utility
//!
//! `my_utility` is a collection of useful utilities.

/// Adds two numbers together.
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

/// Greets a person by name.
pub fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add() {
        assert_eq!(add(2, 3), 5);
    }

    #[test]
    fn test_greet() {
        assert_eq!(greet("World"), "Hello, World!");
    }
}
# Publishing
cargo login
cargo package
cargo publish

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro