mesa_dev/lib.rs
1//! # mesa-dev
2//!
3//! Rust SDK for the [mesa.dev](https://mesa.dev) API.
4//!
5//! **Note:** A large part of this documentation was generated with the assistance
6//! of an LLM. If you spot inaccuracies, please open an issue.
7//!
8//! This crate provides a typed, async-first client for managing repositories,
9//! branches, commits, content, diffs, and API keys on the Mesa platform.
10//!
11//! # Quick Start
12//!
13//! With the default `reqwest-client` feature enabled:
14//!
15//! ```rust,no_run
16//! use mesa_dev::{Mesa, MesaError, models::CreateRepoRequest};
17//!
18//! # async fn run() -> Result<(), MesaError> {
19//! let client = Mesa::new("my-api-key");
20//!
21//! let repo = client
22//! .repos("my-org")
23//! .create(&CreateRepoRequest {
24//! name: "my-repo".to_owned(),
25//! default_branch: None,
26//! })
27//! .await?;
28//!
29//! // Auto-paginate through all branches
30//! let branches = client
31//! .branches("my-org", "my-repo")
32//! .list_all()
33//! .collect()
34//! .await?;
35//! # Ok(())
36//! # }
37//! ```
38//!
39//! # Client Configuration
40//!
41//! Use [`ClientBuilder`] for fine-grained control over timeouts, retries, and
42//! base URL:
43//!
44//! ```rust,no_run
45//! use std::time::Duration;
46//! use mesa_dev::ClientBuilder;
47//!
48//! let client = ClientBuilder::new("my-api-key")
49//! .timeout(Duration::from_secs(60))
50//! .max_retries(5)
51//! .build();
52//! ```
53//!
54//! # Custom HTTP Backends
55//!
56//! The SDK is generic over its HTTP transport. Implement [`HttpClient`] to use
57//! any HTTP library, add middleware, or mock requests in tests:
58//!
59//! ```rust
60//! use mesa_dev::{ClientBuilder, HttpClient, HttpRequest, HttpResponse, error::HttpClientError};
61//!
62//! struct MyClient;
63//!
64//! impl HttpClient for MyClient {
65//! async fn send(
66//! &self,
67//! request: HttpRequest,
68//! ) -> Result<HttpResponse, HttpClientError> {
69//! todo!("implement your HTTP transport here")
70//! }
71//! }
72//!
73//! let client = ClientBuilder::new("my-api-key").build_with(MyClient);
74//! ```
75//!
76//! See the [`HttpClient`] trait documentation for a detailed guide on
77//! implementing custom backends, including how to map errors for correct retry
78//! behavior.
79//!
80//! # Feature Flags
81//!
82//! | Feature | Description | Default |
83//! |---------|-------------|---------|
84//! | `reqwest-client` | Async HTTP backend via reqwest | Yes |
85//! | `ureq-client` | Blocking HTTP backend via ureq | No |
86//!
87//! To disable all built-in backends (for custom implementations only), use:
88//!
89//! ```toml
90//! mesa-dev = { version = "0.1", default-features = false }
91//! ```
92
93pub mod backends;
94mod client;
95pub mod error;
96mod http_client;
97pub mod models;
98mod pagination;
99pub mod resources;
100
101#[cfg(feature = "reqwest-client")]
102pub use client::Mesa;
103pub use client::{ClientBuilder, ClientConfig, MesaClient};
104
105pub use error::{ApiErrorCode, HttpClientError, MesaError};
106
107pub use http_client::{HttpClient, HttpRequest, HttpResponse};
108
109pub use pagination::PageStream;
110
111#[cfg(feature = "reqwest-client")]
112pub use backends::ReqwestClient;
113#[cfg(feature = "ureq-client")]
114pub use backends::UreqClient;