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 moreSource§impl Debug for StoreState
impl Debug for StoreState
Source§impl Default for StoreState
impl Default for StoreState
Source§fn default() -> StoreState
fn default() -> StoreState
impl Eq for StoreState
Source§impl PartialEq for StoreState
impl PartialEq for StoreState
impl StructuralPartialEq for StoreState
Auto Trait Implementations§
impl Freeze for StoreState
impl RefUnwindSafe for StoreState
impl Send for StoreState
impl Sync for StoreState
impl Unpin for StoreState
impl UnsafeUnpin for StoreState
impl UnwindSafe for StoreState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.