Rust based firebase library.
rust
extern crate firebase_rs;
use firebase_rs::*;
rust
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap();
rust
let _firebase = Firebase::auth("https://myfirebase.firebaseio.com", "AUTH_KEY").unwrap();
rust
let users = _firebase.at("users").unwrap();
let res = users.get().unwrap();
````rust use serde::{Deserialize, Serialize};
pub struct User {
username: String,
}
let users = firebase.at("users").unwrap();
let res = users.getgeneric::
// Use this type if you use key value struct (e.g: "user1": {"username": "value"})
let res = users.get_generic::
rust
let job = users.get_async(|res| {
println!("{:?}", res);
});
job.join();
rust
let users = _firebase.at("users").unwrap();
let res = users.set("{\"username\": \"test\"}").unwrap();
rust
let users = _firebase.at("users").unwrap();
let res = users.set_generic::<User>(User {username: "value".to_string()}).unwrap();
rust
let job = users.set_async("{\"username\": \"test\"}", |res| {
println!("{:?}", res);
});
job.join();
rust
let users = _firebase.at("users/user1").unwrap();
let res = users.update("{\"username\": \"new_username\"}").unwrap();
rust
let users = _firebase.at("users/user1").unwrap();
let job = users.update_async("{\"username\": \"new_username\"}", |res| {
println!("{:?}", res);
});
job.join();
rust
let users = _firebase.at("users").unwrap();
let res = users.push("{\"username\": \"test\"}").unwrap();
rust
let job = users.push_async("{\"username\": \"test\"}", |res| {
println!("{:?}", res);
});
job.join();
rust
let user = _firebase.at("users").unwrap();
let res = users.delete("{\"user_id\": \"1\"}").unwrap();
rust
let user = _firebase.at("users").unwrap();
let job = users.delete_async("{\"user_id\": \"1\"}", |res| {
println!("{:?}", res);
});
job.join();