revenuecat/lib.rs
1//! # revenuecat-rs
2//!
3//! RevenueCat SDK for Rust, implemented as an independent direct port of
4//! behavior in the official [purchases-ios], [purchases-android], and
5//! [purchases-js] SDKs (all MIT). Compatibility is tracked per feature across
6//! the backend wire contract and native purchase lifecycle; this crate does
7//! not link those SDKs or claim parity with their UI surfaces.
8//!
9//! ```no_run
10//! use revenuecat::{CacheFetchPolicy, Configuration, Purchases};
11//!
12//! # async fn run() -> revenuecat::Result<()> {
13//! let purchases = Purchases::configure(
14//! Configuration::builder("test_your_api_key")
15//! .app_user_id("my-user")
16//! .build()?,
17//! )?;
18//!
19//! let offerings = purchases.get_offerings().await?;
20//! if let Some(package) = offerings.current().and_then(|o| o.monthly()) {
21//! let result = purchases.purchase_package(package).await?;
22//! assert!(result.customer_info.entitlements.is_active("pro"));
23//! }
24//!
25//! let info = purchases.get_customer_info(CacheFetchPolicy::default()).await?;
26//! println!("active: {:?}", info.active_subscriptions());
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! With a `test_` (Test Store) API key the built-in [`SimulatedStoreBilling`]
32//! is used and no native store is required — purchases are simulated
33//! end-to-end against the backend, which is how the Tauri demo and the
34//! integration tests run on desktop. For real stores, implement
35//! [`StoreBilling`] over StoreKit / Play Billing (e.g. from a Tauri mobile
36//! plugin) and pass it via [`ConfigurationBuilder::store_billing`].
37//!
38//! [purchases-ios]: https://github.com/RevenueCat/purchases-ios
39//! [purchases-android]: https://github.com/RevenueCat/purchases-android
40//! [purchases-js]: https://github.com/RevenueCat/purchases-js
41
42mod backend;
43mod billing;
44mod cache;
45mod configuration;
46mod diagnostics;
47mod error;
48mod http;
49mod identity;
50mod models;
51mod purchases;
52mod security;
53
54pub use backend::ReceiptRequest;
55pub use billing::{SimulatedStoreBilling, StoreBilling};
56pub use configuration::{
57 ApiKeyKind, Configuration, ConfigurationBuilder, EntitlementVerificationMode, Platform,
58 DEFAULT_API_BASE,
59};
60pub use error::{Error, ErrorCode, Result};
61pub use identity::{
62 generate_anonymous_id, is_anonymous_id, ANONYMOUS_ID_PREFIX, MAX_APP_USER_ID_BYTES,
63};
64pub use models::*;
65pub use purchases::{CacheFetchPolicy, PurchaseResult, Purchases};
66pub use security::ROOT_PUBLIC_KEY_B64;