pub struct LicenseManager { /* private fields */ }Expand description
The license state machine: one per app, created by the plugin and reached
with LicensemanagerExt::license.
On creation it validates the stored license key (in the background when the stored token is valid) and begins a periodic clock-tamper check. The plugin disposes it when the app exits.
Implementations§
Source§impl LicenseManager
impl LicenseManager
Sourcepub async fn fingerprint(&self) -> String
pub async fn fingerprint(&self) -> String
Stable per-machine, per-install, per-product fingerprint:
{base64 sha256 of the machine id}:{random install id}:{product id}.
Cached after the first call.
Sourcepub fn state(&self) -> LicenseState
pub fn state(&self) -> LicenseState
The current state.
Sourcepub async fn ready(&self) -> LicenseState
pub async fn ready(&self) -> LicenseState
Resolves with the state once startup validation has completed, or as soon as the stored token is found valid; the online validation then continues in the background. Every caller gets the same state.
Sourcepub fn on_state_change<F>(&self, listener: F) -> Subscription
pub fn on_state_change<F>(&self, listener: F) -> Subscription
Call listener on every state change, until the returned
Subscription is dropped. A panicking listener is ignored.
Sourcepub fn subscribe(&self) -> Receiver<LicenseState>
pub fn subscribe(&self) -> Receiver<LicenseState>
A receiver of the current state and every change.
Sourcepub async fn set_license_key(
&self,
input: &str,
) -> Result<LicenseState, LicenseError>
pub async fn set_license_key( &self, input: &str, ) -> Result<LicenseState, LicenseError>
Validate a key the user typed and, on success, store it and activate. The key is trimmed but its case is kept.
Fails when validation fails for any reason, including the server being unreachable. Nothing is stored and the current state is left untouched.
Sourcepub async fn refresh(&self) -> LicenseState
pub async fn refresh(&self) -> LicenseState
Re-validate the stored key now, e.g. after the customer renewed an expired license. Never fails.
Sourcepub fn license_key(&self) -> Option<String>
pub fn license_key(&self) -> Option<String>
The stored license key, or None before one was set.
Sourcepub fn portal_url(&self) -> String
pub fn portal_url(&self) -> String
Link to the customer portal for this product.
Sourcepub fn latest_allowed_version(&self) -> LatestAllowedVersion
pub fn latest_allowed_version(&self) -> LatestAllowedVersion
In state VERSION_NOT_ALLOWED: the latest version the license allows.
NotApplicable otherwise, and
when the refusal came from the stored token while offline (it only
knows the max version, not the latest release).
Sourcepub fn offline_state(&self) -> OfflineState
pub fn offline_state(&self) -> OfflineState
Whether the last validation reached the server. When offline, the app
keeps running on the stored token until valid_until.
Sourcepub fn is_clock_tampered(&self) -> bool
pub fn is_clock_tampered(&self) -> bool
True once a backwards clock jump has been observed.