| Crates.io | keycrate |
| lib.rs | keycrate |
| version | 1.0.0 |
| created_at | 2025-10-21 00:09:21.649653+00 |
| updated_at | 2025-10-21 00:09:21.649653+00 |
| description | License authentication SDK for Keycrate |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1892910 |
| size | 49,556 |
License authentication SDK for Rust projects.
Add this to your Cargo.toml:
[dependencies]
keycrate = "1.0.0"
use keycrate::{LicenseAuthClient, AuthenticateOptions};
#[tokio::main]
async fn main() {
let client = LicenseAuthClient::new(
"https://api.example.com",
"your-app-id"
);
let opts = AuthenticateOptions {
license: Some("your-license-key".to_string()),
..Default::default()
};
match client.authenticate(opts).await {
Ok(result) => {
if result.success {
println!("License verified!");
} else {
println!("Error: {}", result.message);
}
}
Err(e) => eprintln!("Request failed: {}", e),
}
}
let opts = AuthenticateOptions {
username: Some("user@example.com".to_string()),
password: Some("password123".to_string()),
..Default::default()
};
let result = client.authenticate(opts).await?;
let opts = AuthenticateOptions {
license: Some("your-license-key".to_string()),
hwid: Some("device-id-12345".to_string()),
..Default::default()
};
let result = client.authenticate(opts).await?;
use keycrate::RegisterOptions;
let opts = RegisterOptions {
license: "your-license-key".to_string(),
username: "newuser@example.com".to_string(),
password: "securepassword".to_string(),
};
let result = client.register(opts).await?;
if result.success {
println!("Registration successful!");
} else {
println!("Error: {}", result.message);
}
LicenseAuthClient::new(host, app_id)Creates a new Keycrate client.
Parameters:
host (impl Intoapp_id (impl IntoReturns: LicenseAuthClient instance
client.authenticate(opts) -> Result<AuthResponse, Box<dyn Error>>Authenticate using either a license key or username/password.
Parameters:
opts.license (Optionopts.username (Optionopts.password (Optionopts.hwid (OptionReturns: Result<AuthResponse, Box<dyn Error>>
client.register(opts) -> Result<AuthResponse, Box<dyn Error>>Register credentials for a license.
Parameters:
opts.license (String, required): License keyopts.username (String, required): Usernameopts.password (String, required): PasswordReturns: Result<AuthResponse, Box<dyn Error>>
All methods return an AuthResponse:
pub struct AuthResponse {
pub success: bool,
pub message: String,
pub data: Option<serde_json::Value>,
}
MIT