Skip to main content

LicenseValidator

Struct LicenseValidator 

Source
pub struct LicenseValidator { /* private fields */ }
Expand description

License validator that checks keys against the API with caching.

The validator implements a multi-tier validation strategy:

  1. Check key format (must start with sub_)
  2. Check local cache for fresh result
  3. Call API if cache is stale or missing
  4. Fall back to stale cache if network fails

§Examples

use logicaffeine_verify::LicenseValidator;

let validator = LicenseValidator::new();

// Validate a license key
match validator.validate("sub_abc123") {
    Ok(plan) => {
        if plan.can_verify() {
            println!("Verification enabled with {} plan", plan);
        }
    }
    Err(e) => eprintln!("License error: {}", e),
}

Implementations§

Source§

impl LicenseValidator

Source

pub fn new() -> Self

Create a new license validator.

The validator stores its cache in the system cache directory:

  • macOS/Linux: ~/.cache/logos/verification_license.json
  • Windows: %LOCALAPPDATA%\logos\verification_license.json
§Examples
use logicaffeine_verify::LicenseValidator;

let validator = LicenseValidator::new();
Source

pub fn validate(&self, key: &str) -> VerificationResult<LicensePlan>

Validate a license key.

Returns the license plan if valid and verification-capable. Returns an error if the key is invalid, the plan doesn’t include verification, or network validation fails.

§Validation Steps
  1. Format check: Key must start with sub_
  2. Cache check: Return cached result if < 24 hours old
  3. API call: Validate against api.logicaffeine.com
  4. Fallback: Use stale cache if network fails
§Errors
  • LicenseInvalid - Key format is wrong or API rejected it
  • LicenseInsufficientPlan - License valid but plan lacks verification
§Examples
use logicaffeine_verify::LicenseValidator;

let validator = LicenseValidator::new();

// Invalid format
assert!(validator.validate("invalid").is_err());

// Valid key (requires network)
let result = validator.validate("sub_abc123");

Trait Implementations§

Source§

impl Default for LicenseValidator

Source§

fn default() -> Self

Returns the “default value” for a 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.

§

impl<T, A> IntoAst<A> for T
where T: Into<A>, A: Ast,

§

fn into_ast(self, _a: &A) -> A

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.