pub enum SigningCredential {
Hmac(Credential),
Ed25519(Box<Ed25519Credential>),
}Expand description
Unified signing credential that auto-detects Ed25519 vs HMAC key type.
Binance supports two signing methods:
- HMAC SHA256 (hex-encoded signature) for REST API and standard WebSocket
- Ed25519 (base64-encoded signature) for WebSocket API and SBE streams
The key type is detected from the secret format: if the secret decodes as valid base64 with 32+ bytes (raw seed or PKCS#8), Ed25519 is used. Otherwise HMAC is used.
Variants§
Implementations§
Source§impl SigningCredential
impl SigningCredential
Sourcepub fn new(api_key: String, api_secret: String) -> Self
pub fn new(api_key: String, api_secret: String) -> Self
Creates a new signing credential, auto-detecting Ed25519 vs HMAC.
Tries Ed25519 first (base64-decoded secret must be a valid Ed25519 key). Falls back to HMAC if Ed25519 parsing fails.
Sourcepub fn sign(&self, message: &str) -> String
pub fn sign(&self, message: &str) -> String
Signs a message string and returns the signature.
For HMAC: returns lowercase hex digest. For Ed25519: returns base64-encoded signature.
Sourcepub fn is_ed25519(&self) -> bool
pub fn is_ed25519(&self) -> bool
Returns whether this credential uses Ed25519 signing.
Trait Implementations§
Source§impl Clone for SigningCredential
impl Clone for SigningCredential
Source§fn clone(&self) -> SigningCredential
fn clone(&self) -> SigningCredential
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 moreAuto Trait Implementations§
impl Freeze for SigningCredential
impl RefUnwindSafe for SigningCredential
impl Send for SigningCredential
impl Sync for SigningCredential
impl Unpin for SigningCredential
impl UnsafeUnpin for SigningCredential
impl UnwindSafe for SigningCredential
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
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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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