pub struct SignatureGenerator { /* private fields */ }Expand description
A generator for creating cryptographic signatures with support for various key types and configurations.
This struct manages different authentication mechanisms including API secrets, private keys, and supports multiple key formats (file-based or raw bytes). It uses lazy initialization for key loading and supports different cryptographic key types like OpenSSL private keys and Ed25519 signing keys.
§Fields
api_secret: Optional API secret for signature generationprivate_key: Optional private key source (file or raw bytes)private_key_passphrase: Optional passphrase for decrypting private keysraw_key_data: Lazily initialized raw key data as a stringkey_object: Lazily initialized OpenSSL private keyed25519_signing_key: Lazily initialized Ed25519 signing key
Implementations§
Source§impl SignatureGenerator
impl SignatureGenerator
pub fn new( api_secret: Option<String>, private_key: Option<PrivateKey>, private_key_passphrase: Option<String>, ) -> Self
Sourcepub fn get_signature(
&self,
query_params: &BTreeMap<String, Value>,
) -> Result<String>
pub fn get_signature( &self, query_params: &BTreeMap<String, Value>, ) -> Result<String>
Generates a signature for the given query parameters using either HMAC-SHA256 or asymmetric key signing.
§Arguments
query_params- A map of query parameters to be signed
§Returns
A base64-encoded signature string
§Errors
Returns an error if:
- No API secret or private key is provided
- Key initialization fails
- Signing process encounters an error
- An unsupported key type is used
§Supported Key Types
- HMAC with API secret
- RSA private key
- ED25519 private key
Trait Implementations§
Source§impl Clone for SignatureGenerator
impl Clone for SignatureGenerator
Source§fn clone(&self) -> SignatureGenerator
fn clone(&self) -> SignatureGenerator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SignatureGenerator
impl Debug for SignatureGenerator
Source§impl Default for SignatureGenerator
impl Default for SignatureGenerator
Source§fn default() -> SignatureGenerator
fn default() -> SignatureGenerator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for SignatureGenerator
impl RefUnwindSafe for SignatureGenerator
impl Send for SignatureGenerator
impl Sync for SignatureGenerator
impl Unpin for SignatureGenerator
impl UnwindSafe for SignatureGenerator
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