You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Deepgram<K> struct is generic over the API key K. The signature is:
pubstructDeepgram<K>whereK:AsRef<str>,
I propose K is cloned and stored internally in a String.
Context
There is no obvious benefit to the API user to be generic over an API key. I can see two reasons to do this, and neither seem to hold up.
Save space. However it's 40 bytes as a string (and looks like a hexadecimal number, so I assume it can be stored as a number too?). It seems to be a very small gain.
Allow user to control storage of the API key. In a security paranoid environment maybe it would be possible to hold the key in a "secure enclave" or similar tech. Though AsRef would defeat this, since a simple operation is supposed to release the key. If I don't want the Deepgram struct to remain in memory with the key, I can simply drop the struct. If the API want to ensure the key is zeroed out from memory, the API can impl Drop for Deepgram and zero the memory where the key was stored.
The `Deepgram` struct is unnecessarily generic. Storing the API key as a
generic offers flexibility which probably isn't warranted by any use
cases.
Fixes#49
Proposed changes
The
Deepgram<K>
struct is generic over the API keyK
. The signature is:I propose
K
is cloned and stored internally in aString
.Context
There is no obvious benefit to the API user to be generic over an API key. I can see two reasons to do this, and neither seem to hold up.
AsRef
would defeat this, since a simple operation is supposed to release the key. If I don't want theDeepgram
struct to remain in memory with the key, I can simply drop the struct. If the API want to ensure the key is zeroed out from memory, the API canimpl Drop for Deepgram
and zero the memory where the key was stored.Possible Implementation
The text was updated successfully, but these errors were encountered: