pub struct LicenseKey { /* private fields */ }Expand description
Secure license key with automatic memory protection
This type provides secure storage and handling of Truthlinked license keys with the following security guarantees:
§Security Features
- Memory Protection: Key data is automatically zeroized when dropped
- No Credential Leakage: Debug and Display implementations show only redacted versions
- Safe Serialization: Serialization outputs redacted version, never full key
- Constant-Time Operations: Where applicable, operations are constant-time
§Thread Safety
This type is Send + Sync and can be safely shared across threads.
§Example
use truthlinked_sdk::LicenseKey;
let key = LicenseKey::new("tl_free_secret123".to_string());
// Safe to log - shows redacted version
println!("Using key: {}", key); // "tl_...123"
// Key is automatically zeroized when dropped
drop(key);Implementations§
Source§impl LicenseKey
impl LicenseKey
Sourcepub fn new(key: String) -> Self
pub fn new(key: String) -> Self
Creates a new license key with memory protection
The provided key string will be stored securely and automatically zeroized from memory when this instance is dropped.
§Arguments
key- The license key string (e.g., “tl_free_…”)
§Security
The key is immediately moved into secure storage and will be zeroized when this instance goes out of scope.
Sourcepub fn redacted(&self) -> String
pub fn redacted(&self) -> String
Returns a redacted version of the license key safe for logging
The redacted version shows only the first 3 and last 3 characters of the license key, with the middle portion replaced by “…”.
§Example
let key = LicenseKey::new("tl_free_secret123456789".to_string());
assert_eq!(key.redacted(), "tl_...789");§Security
This method is safe to use in logs, error messages, and debug output as it does not reveal the full license key.
Trait Implementations§
Source§impl Clone for LicenseKey
impl Clone for LicenseKey
Source§fn clone(&self) -> LicenseKey
fn clone(&self) -> LicenseKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more