pub struct StoreState {
pub phase: StorePhase,
pub products: Vec<Product>,
pub owned: BTreeSet<String>,
pub orders: BTreeMap<String, String>,
pub error: Option<String>,
pub busy: bool,
}Expand description
Snapshot of everything known about the store right now.
Fields§
§phase: StorePhaseHow far along the connection is.
products: Vec<Product>Products the backend was configured with and the store answered for. A configured product missing here is one the store does not know — usually a typo in the id, or a product not yet approved.
owned: BTreeSet<String>Product ids the account currently owns. For non-consumables and subscriptions this is the entitlement; consumables never appear.
orders: BTreeMap<String, String>The store’s identifier for the purchase that granted each owned product — Play’s order id, StoreKit’s transaction id.
Separate from owned rather than replacing it, because
a backend can know that a product is owned without knowing what paid
for it: Play’s queryPurchases omits the order id for a test purchase,
and a restore on a reinstalled app can report ownership before the
receipt is back. Ownership is the entitlement; this is only the paper
trail. Never gate access on it.
An app that keeps a local record of the purchase wants it: with only the product id there is nothing to quote to the store, or to the user, if the entitlement is ever in dispute.
error: Option<String>Last error reported by the store, for diagnostics. A store being briefly unreachable is normal and not worth showing to the user.
busy: boolTrue while a purchase or restore the user asked for is still running, so the UI can disable the buy button and show a spinner.
Implementations§
Source§impl StoreState
impl StoreState
Sourcepub fn order_id(&self, product_id: &str) -> Option<&str>
pub fn order_id(&self, product_id: &str) -> Option<&str>
The store’s identifier for the purchase that granted product_id, if
the backend reported one. See orders: absent is
normal and does not mean unowned.
Sourcepub fn product(&self, product_id: &str) -> Option<&Product>
pub fn product(&self, product_id: &str) -> Option<&Product>
The product with product_id, if the store answered for it.
Sourcepub fn display_price(&self, product_id: &str) -> Option<&str>
pub fn display_price(&self, product_id: &str) -> Option<&str>
The localized price of product_id, if known.
Trait Implementations§
Source§impl Clone for StoreState
impl Clone for StoreState
Source§fn clone(&self) -> StoreState
fn clone(&self) -> StoreState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more