mesa-dev 0.1.1

Rust SDK for the mesa.dev API
Documentation

mesa-dev

Rust SDK for the mesa.dev API — manage repositories, branches, commits, content, diffs, and API keys programmatically.

API Documentation

Installation

cargo add mesa-dev

Quick Start

use mesa_dev::{Mesa, MesaError, models::CreateRepoRequest};

#[tokio::main]
async fn main() -> Result<(), MesaError> {
    let client = Mesa::new("my-api-key");

    // Create a repository
    let repo = client
        .repos("my-org")
        .create(&CreateRepoRequest {
            name: "my-repo".to_owned(),
            default_branch: None,
        })
        .await?;
    println!("Created repo: {}", repo.name);

    // List all branches (automatically paginates)
    let branches = client
        .branches("my-org", "my-repo")
        .list_all()
        .collect()
        .await?;
    println!("Found {} branches", branches.len());

    Ok(())
}

Resources

Resource Accessor Operations
Repos client.repos(org) create, list, get, rename, delete
Branches client.branches(org, repo) create, list, delete
Commits client.commits(org, repo) create, list, get, create_with_lfs
Content client.content(org, repo) get (files and directories)
Diffs client.diffs(org, repo) get
LFS client.lfs(org, repo) upload
Admin client.admin(org) API key management

Paginated endpoints expose a list_all() method that returns a PageStream with lazy cursor-based iteration.

Uploading Large Files (LFS)

Use the upload_large_files helper to upload large files to a repository without cloning:

use mesa_dev::{Mesa, MesaError};
use mesa_dev::helpers::{upload_large_files, LargeFile, UploadLargeFilesOptions};
use mesa_dev::models::Author;

#[tokio::main]
async fn main() -> Result<(), MesaError> {
    let client = Mesa::new("my-api-key");
    let content = std::fs::read("large-model.bin").unwrap();

    let commit = upload_large_files(
        &client,
        UploadLargeFilesOptions {
            org: "my-org".into(),
            repo: "my-repo".into(),
            branch: "main".into(),
            message: "Add large model file".into(),
            author: Author {
                name: "Deploy Bot".into(),
                email: "deploy@example.com".into(),
                date: None,
            },
            files: vec![LargeFile {
                path: "models/classifier.bin".into(),
                content,
            }],
            base_sha: None,
        },
    ).await?;

    println!("Created commit: {}", commit.sha);
    Ok(())
}

This helper automatically:

  1. Computes SHA-256 hashes for each file
  2. Uploads content to LFS storage via pre-signed URLs
  3. Creates a commit with LFS pointer files

HTTP Backends

The SDK is generic over its HTTP transport via the HttpClient trait.

Feature Backend Async Default
reqwest-client reqwest yes yes
ureq-client ureq no no

You can also bring your own backend by implementing HttpClient. See the trait documentation for a full guide.

Retry

All requests are retried with exponential backoff and jitter (up to 3 attempts by default). Retryable conditions: HTTP 429, 5xx responses, timeouts, and connection errors. Retry parameters are configurable via ClientBuilder.

Minimum Supported Rust Version

Rust 1.85+ (edition 2024).


Note: A large part of this documentation was generated with the assistance of an LLM. If you spot inaccuracies, please open an issue.