# GitDB Rust SDK Publishing Guide
## Overview
This guide covers publishing the GitDB Rust SDK to crates.io, the official Rust package registry.
## Prerequisites
### 1. crates.io Account
- Create an account at https://crates.io
- Verify your email address
- Generate an API token at https://crates.io/settings/tokens
### 2. Cargo Installation
Ensure you have Cargo (Rust's package manager) installed:
```bash
# Check if Cargo is installed
cargo --version
# If not installed, install Rust from https://rustup.rs
## Publishing Steps
### 1. Login to crates.io
```bash
cd sdk/rust
cargo login
# Enter your API token when prompted
```
### 2. Verify Package Configuration
Check the `Cargo.toml` file:
```toml
[package]
name = "gitdb-client"
version = "1.0.0"
edition = "2021"
description = "Official Rust client for GitDB - GitHub-backed NoSQL database"
authors = ["AFOT Team <team@afot.com>", "karthikeyanV2K <karthikeyan@afot.com>"]
license = "MIT"
repository = "https://github.com/karthikeyanV2K/GitDB"
keywords = ["gitdb", "database", "nosql", "github", "client", "sdk"]
categories = ["database", "web-programming::http-client"]
```
### 3. Test the Package
```bash
# Run tests
cargo test
# Check package
cargo check
# Build the package
cargo build --release
```
### 4. Publish to crates.io
```bash
# Publish the package
cargo publish
```
### 5. Verify Publication
After publishing, verify the package is available:
```bash
# Search for the package
cargo search gitdb-client
# View package details
cargo show gitdb-client
```
## Package Information
### Package Name
- **Name**: `gitdb-client`
- **Registry**: crates.io
- **Current Version**: 1.0.0
### Dependencies
- `reqwest = { version = "0.11", features = ["json"] }` - HTTP client
- `tokio = { version = "1.0", features = ["full"] }` - Async runtime
- `serde = { version = "1.0", features = ["derive"] }` - Serialization
- `serde_json = "1.0"` - JSON handling
- `anyhow = "1.0"` - Error handling
### Features
- Async/await support
- JSON serialization/deserialization
- Error handling with anyhow
- HTTP client with reqwest
- Full CRUD operations for GitDB
## Usage Example
```rust
use gitdb_client::GitDBClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = GitDBClient::new("your-token", "owner", "repo");
// Insert a document
let document = serde_json::json!({
"name": "John Doe",
"email": "john@example.com"
});
let result = client.insert("users", &document).await?;
println!("Inserted document: {:?}", result);
Ok(())
}
```
## Troubleshooting
### Common Issues
1. **Authentication Error**
```bash
cargo login
```
2. **Package Name Already Taken**
- The package name `gitdb-client` should be available
- If taken, consider using `gitdb-rs` or similar
3. **Build Errors**
```bash
cargo clean
cargo build
```
4. **Network Issues**
- Check internet connection
- Verify crates.io is accessible
### Support
- crates.io Documentation: https://doc.rust-lang.org/cargo/reference/publishing.html
- Cargo Book: https://doc.rust-lang.org/cargo/
- Rust Community: https://users.rust-lang.org/
## Post-Publishing
### 1. Update Documentation
- Update the main README.md to include Rust SDK
- Add installation instructions
- Include usage examples
### 2. Version Management
To update the package version:
1. Update `version` in `Cargo.toml`
2. Update `CHANGELOG.md` (if exists)
3. Run `cargo publish`
### 3. Monitoring
- Monitor package downloads
- Respond to issues on GitHub
- Update dependencies as needed
## Quick Publish Script
Create a `publish.bat` file for Windows:
```batch
@echo off
echo Publishing GitDB Rust SDK to crates.io...
cd sdk/rust
cargo login
cargo test
cargo publish
echo Rust SDK published successfully!
pause
```
## Success Criteria
✅ Package is published to crates.io
✅ Package can be installed with `cargo add gitdb-client`
✅ Documentation is accessible
✅ Examples work correctly
✅ All tests pass