Struct firebase_db_access::FirebaseParams
source · pub struct FirebaseParams { /* private fields */ }
Expand description
The FirebaseParams struct is a Firebase reference with attatched query parameters that allow you to sort, limit, and format the data received from Firebase.
It has been made into its own struct because the Firebase API specifies that you can only GET data with query parameters. And so taking advantage of type systems, this struct can only GET data.
You can add any number of parameters to this struct by chaining calls together:
let episodes = Firebase::new("https://futurama.firebaseio.com/episodes/").unwrap();
let alphabetic = episodes.order_by("\"title\"").limit_to_first(5);
let first5 = alphabetic.get();
Setting the same parameter overwrites the previous parameter:
let episodes = Firebase::new("https://arrdev.firebaseio.com/episodes/").unwrap();
// This will create a request that gets entries starting at the 0th index.
let skip10 = episodes.start_at(10).start_at(0);
Implementations
sourceimpl FirebaseParams
impl FirebaseParams
sourcepub fn get(&self) -> Result<Response, i64>
pub fn get(&self) -> Result<Response, i64>
Gets data from Firebase.
Examples
let episodes = Firebase::new("https://futurama.firebaseio.com/episodes/").unwrap();
let alphabetic = episodes.order_by("\"title\"").limit_to_first(5);
let first5 = alphabetic.get();
sourcepub fn get_async<F>(&self, callback: F) -> JoinHandle<()>where
F: Fn(Result<Response, i64>) + Send + 'static,
pub fn get_async<F>(&self, callback: F) -> JoinHandle<()>where
F: Fn(Result<Response, i64>) + Send + 'static,
Asynchronous version of the get method, takes a callback and returns a handle to the thread making the request to Firebase.
sourcepub fn get_url(&self) -> String
pub fn get_url(&self) -> String
Returns the current URL as a string that will be used to make the REST call when talking to Firebase.
sourcepub fn order_by(self, key: &str) -> Self
pub fn order_by(self, key: &str) -> Self
Modifies the current FirebaseParams
instance
and sorts this data by the key provided.
sourcepub fn limit_to_first(self, count: u32) -> Self
pub fn limit_to_first(self, count: u32) -> Self
Modifies the current FirebaseParams
instance
and limits the number of entries returned
on each request to the first count
. Often used with order_by
.
sourcepub fn limit_to_last(self, count: u32) -> Self
pub fn limit_to_last(self, count: u32) -> Self
Modifies the current FirebaseParams
instance
and limits the number of entries returned
on each request to the last count
. Often used with order_by
.
sourcepub fn start_at(self, index: u32) -> Self
pub fn start_at(self, index: u32) -> Self
Modifies the current FirebaseParams
instance
and only returns entries starting after
the specified index. Often used with order_by
.
sourcepub fn end_at(self, index: u32) -> Self
pub fn end_at(self, index: u32) -> Self
Modifies the current FirebaseParams
instance
and only returns entries appearing before
the specified index. Often used with order_by
.
sourcepub fn equal_to(self, value: u32) -> Self
pub fn equal_to(self, value: u32) -> Self
Modifies the current FirebaseParams
instance
and returns only the entry at the specified
index. Often used with order_by
.
Trait Implementations
sourceimpl Clone for FirebaseParams
impl Clone for FirebaseParams
sourcefn clone(&self) -> FirebaseParams
fn clone(&self) -> FirebaseParams
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more