pub struct JetClient { /* private fields */ }Expand description
AT-Jet HTTP Client
A dual-format HTTP client supporting both Protobuf (production) and JSON (debug).
§Example - Protobuf (Production)
use at_jet::prelude::*;
let client = JetClient::new("https://api.example.com")?;
// Type-safe Protobuf requests
let user: User = client.get("/api/user/123").await?;
let created: User = client.post("/api/user", &request).await?;§Example - JSON (Debug)
use at_jet::prelude::*;
let client = JetClient::builder()
.base_url("https://api.example.com")
.debug_key("dev-debug-key")
.build()?;
// Human-readable JSON requests (for debugging)
let user: User = client.get_json("/api/user/123").await?;
let created: User = client.post_json("/api/user", &request).await?;Implementations§
Source§impl JetClient
impl JetClient
Sourcepub fn new(base_url: &str) -> Result<Self>
pub fn new(base_url: &str) -> Result<Self>
Create a new JetClient (Protobuf only)
For JSON debug support, use JetClient::builder().debug_key("key").build().
Sourcepub fn builder() -> JetClientBuilder
pub fn builder() -> JetClientBuilder
Create a new JetClient with custom configuration
Sourcepub async fn get<T>(&self, path: &str) -> Result<T>
pub async fn get<T>(&self, path: &str) -> Result<T>
Make a GET request and decode Protobuf response
Sourcepub async fn post<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>
pub async fn post<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>
Make a POST request with Protobuf body and decode Protobuf response
Sourcepub async fn put<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>
pub async fn put<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>
Make a PUT request with Protobuf body and decode Protobuf response
Sourcepub async fn delete<T>(&self, path: &str) -> Result<T>
pub async fn delete<T>(&self, path: &str) -> Result<T>
Make a DELETE request and decode Protobuf response
Sourcepub async fn post_raw(&self, path: &str, body: Bytes) -> Result<Bytes>
pub async fn post_raw(&self, path: &str, body: Bytes) -> Result<Bytes>
Make a POST request and return raw bytes
Sourcepub async fn get_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
pub async fn get_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
Make a GET request and decode JSON response (debug format)
Requires debug_key to be configured via builder.
Sourcepub async fn post_json<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>where
Req: Serialize,
Res: DeserializeOwned,
pub async fn post_json<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>where
Req: Serialize,
Res: DeserializeOwned,
Make a POST request with JSON body and decode JSON response (debug format)
Requires debug_key to be configured via builder.
Sourcepub async fn put_json<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>where
Req: Serialize,
Res: DeserializeOwned,
pub async fn put_json<Req, Res>(&self, path: &str, body: &Req) -> Result<Res>where
Req: Serialize,
Res: DeserializeOwned,
Make a PUT request with JSON body and decode JSON response (debug format)
Sourcepub async fn delete_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
pub async fn delete_json<T>(&self, path: &str) -> Result<T>where
T: DeserializeOwned,
Make a DELETE request and decode JSON response (debug format)
Sourcepub async fn get_json_raw(&self, path: &str) -> Result<String>
pub async fn get_json_raw(&self, path: &str) -> Result<String>
Make a GET request and return raw JSON string (for inspection)