45 releases (21 breaking)
new 0.31.0 | Mar 24, 2025 |
---|---|
0.29.0 | Mar 13, 2025 |
0.19.1 | Dec 10, 2024 |
0.18.0 | Nov 20, 2024 |
#445 in Magic Beans
968 downloads per month
395KB
10K
SLoC
Versa Rust
This crate is the official Versa SDK for Rust.
Versa uses semantic versioning to ensure the stability of its data model. The current schema version 1.10.0
You can use this crate broadly in two ways: either just referencing the type bindings, or to implement a custom client in Rust.
You will need to enable either the client_sender
or client_receiver
feature to leverage the corresponding client implementation.
Type Bindings
There are broadly two kinds of types represented in this repository: Protocol Bindings and the Receipt Schema
This repository references the root JSON schema files, at https://github.com/versa-protocol/schema, to generate the Rust bindings for a Versa receipt.
Protocol Bindings
Protocol Bindings represent the types of requests, responses, and error codes to be expected when developing client implementations according to the specifications of the Versa Protocol. These types are defined in the protocol
directory.
Receipt Schema
The Receipt struct represents the receipt and invoice data schemas to be handled when developing client implementations according to the specifications of the Versa Protocol. These types are defined in receipt.rs
Build Process
This crate uses the typify crate to construct the receipt schema bindings from our json schema
Features
client
Enables Versa client initialization with customer registration APIsclient_sender
Enables the Versa sending client implementationclient_receiver
Enables the Versa receiving client implementationdiesel
Implements diesel traits for MySQL on certain structs (UNSTABLE: Use with caution)validator
Includes features related to validation of the Versa schema
Schema Validation
The validator feature makes it simple to validate incoming data from the Versa network and to generate a misuse code if necessary. Example usage:
use serde_json::Value;
use versa::protocol::{misuse::MisuseCode, WebhookEventType};
pub async fn validate(event: &WebhookEventType, data: &Value) -> Result<(), (MisuseCode, String)> {
let validator = versa::schema::validator::Validator::new().allow_remote_lookup(true);
validator.validate(event, data).await
}
TODO
- Rust stable crate
- Expanded diesel database support
Dependencies
~8–26MB
~328K SLoC