API Docs can be found here
Rust Firebase
Rust based library for interacting with the Firebase REST API.
Load the crate!
Don't forget to include the library in your project:
extern crate firebase;
use Firebase;
Creating a Firebase reference
Simple
You can currently create a simple reference to your firebase server:
let firebase = new;
Authenticated
Or you can create an authenticated connection by supplying your auth token:
let firebase = authed;
NOTE: You must send your requests through HTTPS or Firebase will reject it. Not specifying HTTPS will also result in an error: ParseError::UrlIsNotHTTPS
Walking the database
Reference nested objects in your server like so:
let show = firebase.at; // points to /shows/futurama
let episode = show.at; // points to /shows/futurama/s10/meanwhile
Slashes and .json extensions will be handled accordingly:
// All of the following are equivalent:
let show = firebase.at;
let show = firebase.at;
let show = firebase.at;
Working with data
Reading data
Reading data can be done with a simple call to .get()
let response = show.get;
Writing data
let description = episode.at;
let response = description.set;
Pushing data
let episodes = firebase.at;
let response = episodes.push;
Updating data
let description = episode.at;
let response = description.update;
Removing data
let episode = firebase.at;
let response = episode.remove;
Requests with parameters
let episodes = firebase.at;
let top5 = episodes.order_by.limit_to_first.get;
The full list of supported parameters are listed here:
order_by
limit_to_first
limit_to_last
start_at
end_at
equal_to
shallow
Not yet there...
Working with JSON values
For now JSON is sent and received as a string literal, an easier method is likely to be implemented in future versions
let json = "{ \"name\": \"David Smith\" }"
let people = firebase.at;
let response = episodes.push;