Skip to main content

LicenseActivator

Struct LicenseActivator 

Source
pub struct LicenseActivator {
    pub state_recv: Receiver<ActivationState>,
    pub error_recv: Receiver<ActivationError>,
    pub poll_online_activation: Arc<AtomicBool>,
    /* private fields */
}
Expand description

Performs license activation.

Fields§

§state_recv: Receiver<ActivationState>

Receiver for the main thread to poll changes to the license activation state.

Once ActivationState::Activated has been received, the consumer can stop reading from this channel, as the license activation won’t be revoked again during this session.

Until the first value is received, the license activation state is undetermined, and the user should just be shown a “loading” state.

§error_recv: Receiver<ActivationError>

Receiver for the main thread to poll errors encountered during license activation.

Which of these you want to display is up to your discretion. You may want to display only the most recent error, or perhaps display each error and make them dismissable.

§poll_online_activation: Arc<AtomicBool>

While this is true, the license activator polls the Moonbase API to check if the user has activated the license online.

Set this to false whenever the user isn’t on the online activation screen to avoid spamming the Moonbase API and getting rate limited.

Implementations§

Source§

impl LicenseActivator

Source

pub fn spawn(cfg: LicenseActivationConfig) -> Self

Creates a new license activator, spawning the background threads that perform license checking.

These background threads run until activation is successful or the LicenseActivator is dropped.

Source

pub fn machine_file_contents(&self) -> String

Creates and returns the contents to write to the machine file used for offline activation.

Source

pub fn submit_offline_activation_token(&mut self, token: &str)

Submits the given offline activation token for validation, caching it on disk if it’s valid.

The result of the validation can be obtained from the state and error receivers as usual.

Trait Implementations§

Source§

impl Drop for LicenseActivator

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.