Creating a client
Building a message
UseMessage::builder() to compose a message. All methods take impl Into<String> or iterables:
.build() validates required fields and returns Err(PauboxError::Validation(...)) if any are missing.
Attachments
Thefrom_bytes constructor base64-encodes the data automatically — no manual encoding needed:
Send a message
SendResponse fields:
| Field | Description |
|---|---|
source_tracking_id | Use to check delivery status |
message | Status message from the API |
Check delivery status
MessageDelivery fields:
| Field | Description |
|---|---|
recipient | Email address |
delivery_status | e.g. delivered, failed, pending |
delivery_time | ISO 8601 timestamp, if delivered |
opened_status | opened or unopened |
opened_time | ISO 8601 timestamp, if opened |
Health check
Ok(()) if the API is reachable, or a PauboxError if not.
Error handling
All methods returnResult<T, PauboxError>. Match on the variants to handle specific conditions:
PauboxError variants:
| Variant | When it occurs |
|---|---|
Auth(String) | HTTP 401 — invalid or missing credentials |
Http { status, body } | Non-2xx response other than 401 |
Request(reqwest::Error) | Network or TLS failure |
Deserialize(serde_json::Error) | Unexpected response format |
Validation(String) | Missing required message field |
EnvVar(String) | Missing environment variable in from_env() |
Url(url::ParseError) | URL construction failure |