dna-rs
An async Rust client library for the Domain Name API REST gateway.
Features
- Full coverage of the Domain Name API REST surface
- Account & balance queries
- Domain availability (bulk search)
- Domain list, detail, registration, renewal
- Contact management
- Name-server and glue record management
- Transfer initiation, approval, rejection, and cancellation
- Lock and privacy protection toggles
- TLD list with pricing matrices
- Production and OTE (sandbox) environments with a single constructor switch
- Structured errors — every failure is a typed
DnaErrorvariant - 113 tests covering success paths, error paths, and edge cases
Requirements
| Dependency | Version |
|---|---|
| Rust | 1.75+ (stable) |
| Tokio | 1.x |
| reqwest | 0.12 |
Installation
Add the crate to your Cargo.toml:
[]
= { = "0.1.0 }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
Quick Start
use DnaClient;
async
Environments
// Production (default)
let client = new?;
// OTE / sandbox
let client = new_ote?;
// Custom URL (useful for testing or proxies)
let client = with_url?;
Error Handling
All methods return DnaResult<T>, which is Result<T, DnaError>.
use DnaError;
match client.get_reseller_details.await
| Variant | When |
|---|---|
Api { code, message, details } |
The gateway returned a non-2xx status |
Http(reqwest::Error) |
Network / TLS / timeout failure |
Deserialize(serde_json::Error) |
Response body is not valid JSON or has an unexpected shape |
UnexpectedResponse(String) |
A required field was missing from an otherwise valid response |
InvalidArgument(String) |
The caller passed an empty or logically invalid argument |
Module Layout
src/
├── lib.rs # Crate root, public re-exports
├── error.rs # DnaError + DnaResult
├── client.rs # DnaClient struct + constructors
├── http.rs # reqwest transport (internal)
├── models/ # All request/response types
│ ├── account.rs # Balance, ResellerDetails, CurrentBalance
│ ├── contact.rs # ContactInfo, ContactInput, ContactPayload
│ ├── domain.rs # DomainInfo, DomainList, AvailabilityResult, …
│ ├── tld.rs # TldInfo, PeriodPriceMap
│ └── transfer.rs # TransferCheckResult, …
└── ops/ # impl DnaClient blocks, one file per domain
├── account.rs
├── availability.rs
├── contact.rs
├── domain.rs
├── nameserver.rs
├── tld.rs
├── transfer.rs
└── util.rs # Private parse helpers
Running Tests
# Run all tests
# Run a specific test file
# Run inline unit tests only
# Run with output visible
License
MIT — see LICENSE.