1 unstable release
0.1.0 | Mar 15, 2023 |
---|
#26 in #firebase
29KB
460 lines
firebase-rs
Rust based Firebase library.
Full Documentation
TODO
- Listen SSE events - In progress (https://github.com/emreyalvac/firebase-rs/pull/11)
- Epoll Integration
How to use
Load library
use firebase_rs::*;
Without Auth
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap();
With Auth
let firebase = Firebase::auth("https://myfirebase.firebaseio.com", "AUTH_KEY").unwrap();
At usage for nested objects
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID").at(...);
Read Data
Read data as string
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
let users = firebase.get_as_string().await;
Read data with generic type (All)
#[derive(Serialize, Deserialize, Debug)]
struct User {
name: String
}
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
let user = firebase.get::<HashMap<String, User>>().await;
Read data with generic type (Single record)
#[derive(Serialize, Deserialize, Debug)]
struct User {
name: String
}
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID");
let user = firebase.get::<User>().await;
Set Data
#[derive(Serialize, Deserialize, Debug)]
struct User {
name: String
}
let user = User { name: String::default() };
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
firebase.set(&user).await;
Update Data
#[derive(Serialize, Deserialize, Debug)]
struct User {
name: String
}
let user = User { name: String::default() };
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID");
firebase.update(&user).await;
With Params
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().with_params().start_at(1).order_by("name").equal_to(5).finish();
let result = firebase.get().await;
Dependencies
~7–19MB
~267K SLoC