Skip to main content

Moonbase

Struct Moonbase 

Source
pub struct Moonbase<R: Runtime>(/* private fields */);
Expand description

The plugin’s license controller, managed as Tauri state. Reach it from Rust with MoonbaseExt::moonbase to gate features or drive activation without the webview.

Every method that talks to Moonbase or the disk blocks; call those from a worker thread or spawn_blocking. state, is_licensed, license and has_sub_product never block on I/O.

Implementations§

Source§

impl<R: Runtime> Moonbase<R>

Source

pub fn licensing(&self) -> &Licensing

The SDK instance behind the plugin, for anything the plugin does not wrap.

Source

pub fn is_licensed(&self) -> bool

Is there a valid license right now? Lock-free, so cheap enough to check anywhere you gate a feature.

Source

pub fn license(&self) -> Option<License>

The license in force, if any.

Source

pub fn has_sub_product(&self, sub_product_id: &str) -> bool

Whether to unlock an add-on on this device: the license in force lists it as active and it hasn’t expired. Takes the add-on’s own part of its product ID ("drum-kit") or its whole ID ("my-app.drum-kit"). False while no license is in force.

Source

pub fn active_sub_products(&self) -> Vec<String>

The add-ons has_sub_product is true for right now, by their own part of their product ID.

Source

pub fn license_file(&self) -> PathBuf

Where the license is kept.

Source

pub fn state(&self) -> LicenseState

A snapshot of the license state, as the UI sees it.

Source

pub fn activate(&self, method: ActivationMethod) -> Result<LicenseState>

Start a browser activation: create the request, open the browser, and poll in the background until it completes. Returns once the request exists, with its link in LicenseState::activation.

ActivationMethod::Offline mints an offline license through the same browser flow, for a machine that has network now but will not later.

Source

pub fn cancel_activation(&self) -> LicenseState

Stop waiting for a browser activation. A license held from before stays.

Source

pub fn refresh(&self, force: bool) -> Result<LicenseState>

Re-check the license against Moonbase and refresh its entitlements in place: call it after a purchase so new features and add-ons load without a restart. force skips the online-validation throttle.

A revoked or lapsed license locks, and so does one that cannot be checked once the offline grace period has run out; within it a network failure keeps the license and returns the error. No-op for offline licenses, and while an activation is in progress (it brings a fresh license of its own).

With Status::NotCovered it re-checks the license that doesn’t cover this version, so once the customer has bought the upgrade the app unlocks.

Source

pub fn deactivate(&self) -> Result<LicenseState>

Free this device’s seat and lock. Offline and trial licenses cannot be revoked, so those are forgotten locally instead. When Moonbase cannot be reached the license is kept, and the error says so. Also hands back the seat of a license that doesn’t cover this version of the app.

Source

pub fn forget(&self) -> LicenseState

Forget the license on this device only, without telling Moonbase.

Source

pub fn device_token(&self) -> Result<String>

The device token (“machine file”) for activating a machine with no network: save it as a .dt file the customer exchanges at https://<tenant>.moonbase.sh/activate for a license file, then pass that file’s contents to activate_offline.

Source

pub fn activate_offline( &self, license_file_contents: &str, ) -> Result<LicenseState>

Activate from the contents of an offline license file.

A license file for this device that doesn’t cover this version of the app is stored anyway, as it still covers the versions it did, and the app locks with Status::NotCovered; the error says so.

Source

pub fn upgrade_license(&self) -> Result<LicenseState>

Offer the upgrade the app needs. With Status::NotCovered, open the upgrade page Moonbase named for the license or, without one, start an online activation, whose browser page offers the upgrade where the store sells one and activates this device once a license covers this version. Otherwise open the upgrade page check_update found for a new version the license doesn’t cover. After the purchase, refresh picks up the upgraded license.

Source

pub fn dismiss_error(&self) -> LicenseState

Clear the last failure, e.g. when the user dismisses its message.

Source

pub fn device(&self) -> DeviceInfo

This device, for diagnostics.

Source

pub fn check_update(&self) -> Result<UpdateInfo>

Whether a newer release than this app is out, with its notes when it is. Only the notes need the network. For a customer whose licenses don’t cover the new version, says so and where to upgrade.

Source

pub fn update_download_url(&self) -> Result<DownloadTarget>

A short-lived download link for the latest installer for this platform.

Fails with moonbase::Error::ReleaseNotCovered, with the upgrade link, when the customer’s licenses don’t cover the release.

Source

pub fn load_add_ons(&self) -> Result<LicenseState>

List the product’s add-ons for this device into LicenseState::add_ons, with their prices, ownership and trials, for a store or upgrade screen.

Can take a seat: with auto_activate_sub_products on (the default), when the list shows an add-on the customer owns, with a seat free, that the license doesn’t hold yet (one bought since the license was last checked), the license is re-checked once, which takes that seat as every check does, and the add-ons are listed again. With the option off it only reads.

Source

pub fn refresh_add_ons(&self) -> Result<LicenseState>

Re-check the license, so an add-on bought since takes its seat, then list the add-ons again: what “Bought an add-on? Refresh” does after a purchase in the browser.

Source

pub fn activate_sub_product(&self, sub_product_id: &str) -> Result<LicenseState>

Take a seat of an add-on the customer owns for this device, from the full license in force: one whose seat was revoked here, or any, with auto_activate_sub_products off. Stores the license that comes back, and lists the add-ons again if they were loaded.

One add-on at a time; why one failed is also in AddOnsState::action_error, worded for the customer. A license the server no longer accepts is re-checked, and locks as refresh would.

Source

pub fn request_sub_product_trial( &self, sub_product_id: &str, ) -> Result<LicenseState>

Start the trial of an add-on the customer doesn’t own on this device, from the full license in force (owning it, they get a seat instead). Otherwise as activate_sub_product.

Source

pub fn buy_sub_product(&self, sub_product_id: &str) -> Result<()>

Open the add-on’s buy link from LicenseState::add_ons in the browser. When the app then goes to the background (the customer is in the browser) and comes back to the front, the add-ons are refreshed as refresh_add_ons does, so one just bought unlocks without a click.

Source§

impl<R: Runtime> Moonbase<R>

Source

pub fn present(&self, screen: Option<Screen>) -> Result<()>

Show the activation window, creating it if needed, and bring it to the front; or, with Presentation::Overlay, mount the overlay over its window. screen opens it on a particular Screen; without one it shows whatever the license state calls for.

Source

pub fn close_ui(&self) -> Result<()>

Close the activation window, or take the overlay down, if it is showing.

Source

pub fn skip_update(&self, version: &str) -> Result<()>

Never prompt for this release again; a newer one still prompts.

Source

pub fn save_machine_file(&self) -> Result<Option<PathBuf>>

Save the machine file for offline activation: through a save dialog when the app has registered tauri-plugin-dialog, otherwise into Downloads, revealed in the file manager. None when the user cancels.

Source

pub fn download_update(&self) -> Result<()>

Download the latest installer for this platform into Downloads, reporting progress to the window, then reveal it.

Source

pub fn reveal_update(&self) -> Result<()>

Show the downloaded installer in the file manager again.

Trait Implementations§

Source§

impl<R: Runtime> Clone for Moonbase<R>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Runtime> Debug for Moonbase<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for Moonbase<R>

§

impl<R> !UnwindSafe for Moonbase<R>

§

impl<R> Freeze for Moonbase<R>
where Arc<Shared<R>>: Freeze,

§

impl<R> Send for Moonbase<R>
where Arc<Shared<R>>: Send,

§

impl<R> Sync for Moonbase<R>
where Arc<Shared<R>>: Sync,

§

impl<R> Unpin for Moonbase<R>
where Arc<Shared<R>>: Unpin,

§

impl<R> UnsafeUnpin for Moonbase<R>
where Arc<Shared<R>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more