pub struct Credential { /* private fields */ }Expand description
L2 API credential with HMAC-SHA256 signing for authenticated requests.
Stores the API key as Ustr (interned, used for lookups) and the
decoded secret as Box<[u8]> (zeroized on drop). The base64 secret and
HMAC key are initialized once to avoid repeated setup per request.
aws-lc-rs cleanses the native HMAC context when the key is dropped.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn new(api_key: &str, api_secret: &str, passphrase: String) -> Result<Self>
pub fn new(api_key: &str, api_secret: &str, passphrase: String) -> Result<Self>
Creates a new credential. The api_secret must be base64-encoded.
pub fn api_key(&self) -> Ustr
pub fn passphrase(&self) -> &str
Sourcepub fn api_secret(&self) -> String
pub fn api_secret(&self) -> String
Returns the raw API secret as a base64-encoded string.
Used for WebSocket user channel authentication which expects the raw secret (not an HMAC signature).
Sourcepub fn sign(
&self,
timestamp: &str,
method: &str,
request_path: &str,
body: &str,
) -> String
pub fn sign( &self, timestamp: &str, method: &str, request_path: &str, body: &str, ) -> String
Signs a request with HMAC-SHA256 and returns the base64-encoded signature.
Message format: {timestamp}{method}{request_path}{body}
Sourcepub fn resolve(
api_key: Option<String>,
api_secret: Option<String>,
passphrase: Option<String>,
) -> Result<Self>
pub fn resolve( api_key: Option<String>, api_secret: Option<String>, passphrase: Option<String>, ) -> Result<Self>
Resolves from provided values, falling back to environment variables.
pub fn from_env() -> Result<Self>
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl Drop for Credential
impl Drop for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnsafeUnpin for Credential
impl UnwindSafe for Credential
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more