pub struct Credentials {
pub instance: String,
pub jwt_token: String,
pub user: Option<UserId>,
pub name: Option<String>,
pub email: Option<String>,
pub expires_at: Option<String>,
pub server_url: Option<String>,
pub refresh_token: Option<String>,
pub refresh_expires_at: Option<String>,
}Expand description
Stored credentials for a KalamDB instance.
Contains a JWT token that can be persisted and reused across sessions.
The token is obtained by authenticating with user/password via the
/v1/api/auth/login endpoint.
Fields§
§instance: StringDatabase instance identifier (e.g., “local”, “production”, URL)
jwt_token: StringJWT access token for authentication Obtained from the login endpoint, expires after a configured period
user: Option<UserId>User associated with this token (for display purposes)
name: Option<String>Preferred human-friendly name for this account, if available.
email: Option<String>Email associated with this token (for display purposes)
expires_at: Option<String>Token expiration time in RFC3339 format (optional, for cache invalidation)
server_url: Option<String>Optional: Server URL if different from instance name
refresh_token: Option<String>Refresh token for obtaining new access tokens (longer-lived)
refresh_expires_at: Option<String>Refresh token expiration time in RFC3339 format
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(instance: String, jwt_token: String) -> Credentials
pub fn new(instance: String, jwt_token: String) -> Credentials
Create new credentials with a JWT token
Sourcepub fn with_details(
instance: String,
jwt_token: String,
user: impl Into<UserId>,
expires_at: String,
server_url: Option<String>,
) -> Credentials
pub fn with_details( instance: String, jwt_token: String, user: impl Into<UserId>, expires_at: String, server_url: Option<String>, ) -> Credentials
Create new credentials with full details
Sourcepub fn with_refresh_token(
instance: String,
jwt_token: String,
user: impl Into<UserId>,
expires_at: String,
server_url: Option<String>,
refresh_token: Option<String>,
refresh_expires_at: Option<String>,
) -> Credentials
pub fn with_refresh_token( instance: String, jwt_token: String, user: impl Into<UserId>, expires_at: String, server_url: Option<String>, refresh_token: Option<String>, refresh_expires_at: Option<String>, ) -> Credentials
Create new credentials with full details including refresh token
Sourcepub fn with_identity_metadata(
self,
name: Option<String>,
email: Option<String>,
) -> Credentials
pub fn with_identity_metadata( self, name: Option<String>, email: Option<String>, ) -> Credentials
Attach human-friendly identity metadata.
Sourcepub fn display_label(&self) -> Option<&str>
pub fn display_label(&self) -> Option<&str>
Preferred display label for this identity.
Sourcepub fn get_server_url(&self) -> &str
pub fn get_server_url(&self) -> &str
Get the server URL, defaulting to instance name if not set
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the access token has expired (if expiration is known) Returns false if expiration is unknown (assume valid)
Sourcepub fn is_refresh_expired(&self) -> bool
pub fn is_refresh_expired(&self) -> bool
Check if the refresh token has expired (if expiration is known) Returns true if no refresh token is available or if it has expired
Sourcepub fn can_refresh(&self) -> bool
pub fn can_refresh(&self) -> bool
Check if we can refresh the access token
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
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 Credentials
impl Debug for Credentials
Source§impl<'de> Deserialize<'de> for Credentials
impl<'de> Deserialize<'de> for Credentials
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Credentials, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Credentials, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
Source§fn eq(&self, other: &Credentials) -> bool
fn eq(&self, other: &Credentials) -> bool
self and other values to be equal, and is used by ==.