17 stable releases

new 2.2.0 Nov 20, 2024
2.1.2 Jun 14, 2024
2.1.1 Apr 17, 2024
2.1.0 Mar 6, 2024
1.0.3 Apr 27, 2020

#359 in Web programming

Download history 75/week @ 2024-07-29 34/week @ 2024-08-05 20/week @ 2024-08-12 46/week @ 2024-08-19 18/week @ 2024-08-26 36/week @ 2024-09-02 26/week @ 2024-09-09 18/week @ 2024-09-16 101/week @ 2024-09-23 45/week @ 2024-09-30 7/week @ 2024-10-07 41/week @ 2024-10-14 42/week @ 2024-10-21 70/week @ 2024-10-28 63/week @ 2024-11-04 23/week @ 2024-11-11

201 downloads per month

MIT license

26KB
425 lines

firebase-rs

Crates.io docs.rs License

Rust based Firebase library.

firebase

Full Documentation

Documentation

Features

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 as Stream

With Real Time Events

let firebase = Firebase::new("https://myfirebase.firebaseio.com").at("users").unwrap();
let stream = firebase.with_realtime_events().unwrap();
stream
.listen( | event_type, data| {
println ! ("Type: {:?} Data: {:?}", event_type, data);
}, | err| println!("{:?}", err), false).await;

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 with Custom Key

#[derive(Serialize, Deserialize, Debug)]
struct User {
    name: String
}

let user = User { name: String::default () };
let mut firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
firebase.set_with_key("myKey", &user).await;

Output

{
  "users": {
    "myKey": {
      "name": ""
    }
  }
}

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;

Output

{
  "users": {
    "-OC9mYIUIdY3JygkmsFQ": {
      "name": ""
    }
  }
}

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;

Contributors

Thanks goes to these wonderful people ✨

Dependencies

~9–21MB
~288K SLoC