pub struct FirebaseRTDB {
pub base_url: String,
pub auth: AuthResponsePayload,
pub expire_time: Instant,
pub api_key: String,
pub jwt: String,
/* private fields */
}
Expand description
Firebase Realtime Database client with JWT authentication support.
This struct maintains the authentication state and provides access to database operations. It automatically handles token renewal and maintains connection settings.
§Fields
base_url
- The base URL of your Firebase projectclient
- HTTP client with connection pooling and TLS supportauth
- Current authentication state including tokensexpire_time
- Token expiration timestampapi_key
- Firebase project API keyjwt
- Original JWT token for renewals
Fields§
§base_url: String
§auth: AuthResponsePayload
§expire_time: Instant
§api_key: String
§jwt: String
Implementations§
Source§impl FirebaseRTDB
impl FirebaseRTDB
Sourcepub async fn new_from_jwt<T: Into<String>, R: Into<String>, V: AsRef<str>>(
project_url: T,
jwt: R,
api_key: V,
) -> Result<Self, RtdbError>
pub async fn new_from_jwt<T: Into<String>, R: Into<String>, V: AsRef<str>>( project_url: T, jwt: R, api_key: V, ) -> Result<Self, RtdbError>
Creates a new Firebase RTDB client using a JWT token.
This method will contact the authorization server to obtain necessary credentials. The JWT token is used for initial authentication and subsequent token renewals.
§Arguments
project_url
- The base URL of your Firebase project (e.g., “https://project-id.firebaseio.com”)jwt
- A valid JWT token for authenticationapi_key
- Your Firebase project’s API key
§Returns
Returns a Result containing the initialized FirebaseRTDB client or an error
Sourcepub fn new_from_token<T: Into<String>, R: Into<String>, V: Into<String>>(
project_url: T,
api_key: R,
jwt: V,
auth: AuthResponsePayload,
expire_time: Instant,
) -> Result<Self, RtdbError>
pub fn new_from_token<T: Into<String>, R: Into<String>, V: Into<String>>( project_url: T, api_key: R, jwt: V, auth: AuthResponsePayload, expire_time: Instant, ) -> Result<Self, RtdbError>
Creates a new Firebase RTDB client using an existing valid token.
Use this method when you already have valid authentication credentials and want to avoid an initial token refresh.
§Arguments
project_url
- The base URL of your Firebase projectapi_key
- Your Firebase project’s API keyjwt
- A valid JWT tokenauth
- Existing authentication payloadexpire_time
- Token expiration time
Sourcepub async fn renew_token(&mut self) -> Result<(), RtdbError>
pub async fn renew_token(&mut self) -> Result<(), RtdbError>
Renews the authentication token.
This method should be called when the current token is about to expire or has expired. It will update the internal authentication state with new credentials.
Sourcepub fn token_expired(&self) -> bool
pub fn token_expired(&self) -> bool
Checks if the current authentication token has expired.
Returns true if the token has expired and needs to be renewed before making further database requests.
Trait Implementations§
Source§impl Clone for FirebaseRTDB
impl Clone for FirebaseRTDB
Source§fn clone(&self) -> FirebaseRTDB
fn clone(&self) -> FirebaseRTDB
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more