> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Publish Rust SDKs manually

This guide covers publishing Rust SDKs manually. For information on automating Rust SDK publishing, see [Publish Rust SDKs automatically](/docs/sdk-generator/publish/rust-auto/).

To share your generated Rust SDK with the community, you can publish it to crates.io. This enables other developers to easily install it using Cargo. Follow the steps below to publish your SDK to crates.io.

## Prerequisites

To publish your SDK to crates.io, you need the following:

* A crates.io account (create at [crates.io](https://crates.io/)).
* Cargo installed with the Rust toolchain.
* API token from crates.io.

## Configure Cargo.toml

Ensure your SDK's `Cargo.toml` is properly configured for publication:

```toml
[package]
name = "your-sdk"
version = "1.0.0"
description = "SDK for Your API"
license = "MIT" # or license-file = "LICENSE"
repository = "https://github.com/your-org/your-sdk"
```

## Publish your Rust SDK to crates.io

To publish your SDK to crates.io, do the following:

1. Create a crates.io account and get an API token:

   * Register at [crates.io](https://crates.io/).
   * Go to **Account Settings > API Tokens**.
   * Create a new token with appropriate permissions.

2. Sign in to crates.io using Cargo:

   ```bash
   cargo login <your-api-token>
   ```

3. Verify your package builds correctly:

   ```bash
   # Check for common issues
   cargo check

   # Run tests
   cargo test

   # Build documentation
   cargo doc

   # Verify package contents
   cargo package --list
   ```

4. Test the package build:

   ```bash
   # This creates a .crate file without publishing
   cargo package
   ```

5. Publish to crates.io:

   ```bash
   cargo publish
   ```

6. Verify publication:

   ```bash
   # In a separate test project, add your published crate as a dependency
   cargo new verify-your-sdk
   cd verify-your-sdk
   cargo add your-sdk

   # Build the project to verify the crate resolves and compiles
   cargo check

   # Or visit: https://crates.io/crates/your-sdk
   ```

   Use `cargo install your-sdk` only if your crate also publishes a binary target.

## Publish updates

To publish a new version of your SDK:

1. Update the version in `Cargo.toml`:

   ```toml
   version = "1.0.1"
   ```

2. Update dependencies if needed and test:

   ```bash
   cargo update
   cargo test
   ```

3. Publish the new version:

   ```bash
   cargo publish
   ```

## Best practices for publishing Rust SDKs

Use the following best practices when publishing your Rust SDK to crates.io:

* Follow semantic versioning (`MAJOR.MINOR.PATCH`).
* Include comprehensive documentation with `cargo doc`.
* Use appropriate keywords and categories for discoverability.
* Test your package thoroughly with `cargo test`.
* Consider using features for optional functionality.
* Keep your API surface minimal and follow Rust naming conventions.
* Use `#[non_exhaustive]` on enums and structs that might grow.
* Provide good error messages and use `thiserror` for error handling.

## Advanced configuration

For production SDKs, consider these additional configurations:

### Custom feature flags

```toml
[features]
default = ["reqwest-default"]
reqwest-default = ["reqwest/default-tls"]
reqwest-rustls = ["reqwest/rustls-tls"]
blocking = ["reqwest/blocking"]
```

### Documentation settings

```toml
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
```

This ensures that `docs.rs` builds your documentation with all features enabled and proper conditional compilation attributes.