Rust
A Rust client SDK for interacting with Verity Prover
The Verity Client SDK is a Rust-based client library that enables interaction with the Verity Prover service. It’s built on top of the reqwest
HTTP client and provides a convenient interface for making verifiable HTTP requests.
To read the docs.rs documentation on the verity-client
crate, please visit: https://usherlabs.github.io/verity-dp/packages/verity-client/doc/verity_client/index.html
Installation
Add the following to your Cargo.toml
:
VerityClient
The main client struct that handles all interactions with the Verity Prover service. It’s built upon reqwest and provides methods for making HTTP requests with built-in verification.
Request Building
The SDK provides a builder pattern for constructing requests. You can:
- Make GET and POST requests
- Add headers
- Set request bodies
- Configure redaction rules
Making Requests
GET Request Example
Here’s how to make a simple GET request:
POST Request with JSON
For POST requests with JSON payload:
Data Redaction
The SDK supports redacting sensitive information from both requests and responses in the generated TLS proofs using the redact()
method:
Response Handling
The SDK returns a VerityResponse
struct containing:
- The original response (
subject
) - A proof of the request/response interaction (
proof
) - The notary’s public key (
notary_pub_key
)
Advanced Features
Notary Information
You can retrieve information about the connected notary:
Response to Proof Timeout
The SDK implements a default proof timeout of 1000ms, after which it will cancel the proof awaiting process if no proof is received. This is the time to wait for a proof received over SSE connection since receiving HTTP response.
Error Handling
The SDK uses anyhow for error handling, providing detailed error information when requests fail. All async operations return Result types that should be properly handled:
Examples
Basic GET Request
POST Request with Redaction
Technical Details
The SDK is built on several key components:
reqwest
for HTTP client functionalitytokio
for async runtimeserde
for JSON serialization/deserialization- Event Source implementation for proof streaming
- UUID v4 for request identification
For more detailed information about the implementation, refer to the source code, review the docs.rs, or contact the Usher Labs team.