pub struct LicenseValidator { /* private fields */ }Expand description
Offline license validator
Implementations§
Source§impl LicenseValidator
impl LicenseValidator
Sourcepub fn new(public_key_hex: &str) -> Result<Self, LicenseError>
pub fn new(public_key_hex: &str) -> Result<Self, LicenseError>
Create a new validator with the given public key (hex-encoded)
§Example
use offline_license_validator::LicenseValidator;
let validator = LicenseValidator::new(
"913d5e19269699e51bcdb5c5a7106c278ef0e0fe92d31b76b6daf5bb00594fcf"
).unwrap();Sourcepub fn validate(
&self,
license_string: &str,
current_hwid: &str,
) -> Result<ValidLicenseInfo, LicenseError>
pub fn validate( &self, license_string: &str, current_hwid: &str, ) -> Result<ValidLicenseInfo, LicenseError>
Validate a license string
§Arguments
license_string- License in format:Base64(payload).Base64(signature)current_hwid- Hardware ID of the current system
§Returns
Ok(ValidLicenseInfo) if license is valid, otherwise Err(LicenseError)
§Example
use offline_license_validator::LicenseValidator;
let validator = LicenseValidator::new("public_key_hex").unwrap();
match validator.validate("license_string", "hwid123") {
Ok(info) => println!("Valid license: {:?}", info),
Err(e) => eprintln!("Invalid license: {}", e),
}Auto Trait Implementations§
impl Freeze for LicenseValidator
impl RefUnwindSafe for LicenseValidator
impl Send for LicenseValidator
impl Sync for LicenseValidator
impl Unpin for LicenseValidator
impl UnsafeUnpin for LicenseValidator
impl UnwindSafe for LicenseValidator
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
Mutably borrows from an owned value. Read more