docs.rs failed to build stateset-primitives-0.7.22
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
stateset-primitives
Strongly-typed primitive types for commerce applications in Rust. Prevents entire classes of bugs at compile time by making it impossible to confuse an OrderId with a CustomerId, or to add Money in different currencies.
Features
- Newtype IDs:
OrderId,CustomerId,ProductId,ShipmentId,PaymentId,InventoryItemId,SubscriptionId,CartId, and 9 more — allCopy + Eq + Hash + Serialize + Display - Money: Amount + currency pair that prevents arithmetic across currencies
- CurrencyCode: ISO 4217 currency codes (USD, EUR, GBP, ...) plus crypto (BTC, ETH, USDC)
- Sku: Validated product SKU (alphanumeric + hyphen/underscore)
- Zero unsafe code,
#[deny(unsafe_code)]
Usage
use ;
use Uuid;
// Type-safe IDs — can't accidentally swap them
let order_id: OrderId = new_v4.into;
let customer_id: CustomerId = new_v4.into;
// Money is currency-aware
let price = new;
// SKUs are validated
let sku: Sku = "WBH-001".parse.unwrap;
Feature Flags
std(default) — Standard library supportarbitrary— Enableproptest::Arbitraryfor property-based testing
License
MIT OR Apache-2.0