Instagres
A Rust SDK for instant PostgreSQL instance provisioning via Neon.
[!IMPORTANT] This crate is under heavy development
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Example
use InstagresClient;
use ;
async
API Methods
post<T>(referrer: impl AsRef<str>, body: impl Serialize) -> Result<T>
Make a POST request and return a typed JSON response.
Parameters:
referrer(required): Your application identifier. Cannot be empty.body: The request body to send as JSON.
Returns: Deserialized response of type T.
Throws: Error if referrer is empty or whitespace.
post_with_headers<T>(referrer: impl AsRef<str>, body: impl Serialize, headers: HashMap<String, String>) -> Result<T>
Make a POST request with custom headers and return a typed JSON response.
Parameters:
referrer(required): Your application identifier. Cannot be empty.body: The request body to send as JSON.headers: Custom HTTP headers to include.
Returns: Deserialized response of type T.
post_raw(referrer: impl AsRef<str>, body: impl Serialize) -> Result<String>
Make a POST request and return the raw JSON string response.
Parameters:
referrer(required): Your application identifier. Cannot be empty.body: The request body to send as JSON.
Returns: Raw JSON string.
Response Structure
The Neon API returns the following structure:
Error Handling
The client will return an error in the following cases:
- Empty referrer: If the referrer parameter is empty or contains only whitespace, an error will be returned with the message:
"referrer is required and cannot be empty" - Network errors: Any network-related issues during the request
- Deserialization errors: If the response cannot be parsed into the expected type
Custom HTTP Client
You can provide your own configured reqwest::Client:
use Client;
use InstagresClient;
let custom_client = builder
.timeout
.build?;
let client = with_client;