[−][src]Struct firebase_rs::Firebase
Methods
impl Firebase
[src]
pub fn new(url: &str) -> Result<Self, UrlParseError>
[src]
Creates a Firebase reference
Failures
- If a url is not HTTPS, UrlParseError::NotHttps
- If a url cannot be parsed into a valid url, UrlParseError::Parser(curl::Error)
Examples
let mut _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap();
pub fn auth(url: &str, auth: &str) -> Result<Self, UrlParseError>
[src]
Creates a new authenticated Firebase reference.
Failures
- If a url is not HTTPS, UrlParseError::NotHttps
- If a url cannot be parsed into a valid url, UrlParseError::Parser(curl::Error)
Examples
let mut _firebase = Firebase::auth("https://myfirebase.firebaseio.com", "AUTH_KEY").unwrap(); The url will be https://myfirebase.firebaseio.com/?auth=AUTH_KEY
pub fn get_url(&self) -> Url
[src]
Returns current URL
pub fn at(&self, add_path: &str) -> Result<Self, UrlParseError>
[src]
Creates a new Firebase instance with path.
Examples
let mut _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); // The URL will be: https://myfirebase.firebaseio.com/movies.json let movies = _firebase.at("movies").unwrap(); OR let movies = _firebase.at("movies/movie1").unwrap();
pub fn set(&self, data: &str) -> Result<Response, RequestError>
[src]
Sets data to Firebase
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); users.set("{\"username\":\"test\"}").unwrap();
pub fn set_async<S, F>(&self, data: S, callback: F) -> JoinHandle<()> where
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
[src]
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
Asynchronous method for set. Takes a callback function and returns a handle.
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users").unwrap(); users = users.at("user_1").unwrap(); let job = users.set_async("{\"username\":\"new_username\"}", |res| { println!("{:?}", res); }); job.join();
pub fn set_generic<T>(
&self,
data: T
) -> Result<ResponseGeneric<T>, RequestError> where
T: DeserializeOwned + Serialize + Sized + Debug,
[src]
&self,
data: T
) -> Result<ResponseGeneric<T>, RequestError> where
T: DeserializeOwned + Serialize + Sized + Debug,
Examples
use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub struct User { username: String } let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); let res = users.set_generic::<User>(User {username: "value".to_string()}).unwrap();
pub fn get_generic<T>(&self) -> Result<ResponseGeneric<T>, RequestError> where
T: DeserializeOwned,
[src]
T: DeserializeOwned,
Gets data from Firebase with generic type
Examples
use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub struct User { username: String } let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); let res = users.get_generic::<User>().unwrap(); // Use this type if you use key value struct (e.g: "user1": {"username": "value"}) let res = users.get_generic::<HashMap<String, User>().unwrap();
pub fn get(&self) -> Result<Response, RequestError>
[src]
Gets data from Firebase
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); let res = users.get().unwrap();
pub fn get_async<F>(&self, callback: F) -> JoinHandle<()> where
F: Fn(Result<Response, RequestError>) + Send + 'static,
[src]
F: Fn(Result<Response, RequestError>) + Send + 'static,
Asynchronous method for get. Takes a callback function and returns a handle.
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users").unwrap(); users = users.at("user_1").unwrap(); let job = users.get_async(|res| { println!("{:?}", res); }); job.join();
pub fn push(&self, data: &str) -> Result<Response, RequestError>
[src]
Push data to Firebase
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); users.push("{\"username\":\"test\"}").unwrap();
pub fn push_async<S, F>(&self, data: S, callback: F) -> JoinHandle<()> where
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
[src]
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
Asynchronous method for push. Takes a callback function and returns a handle.
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users").unwrap(); users = users.at("user_1").unwrap(); let job = users.push_async("{\"username\":\"new_username\"}", |res| { println!("{:?}", res); }); job.join();
pub fn delete(&self, data: &str) -> Result<Response, RequestError>
[src]
Delete data from Firebase
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users").unwrap(); users.delete("{\"user_id\":\"1\"}").unwrap();
pub fn delete_async<S, F>(&self, data: S, callback: F) -> JoinHandle<()> where
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
[src]
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
Asynchronous method for delete. Takes a callback function and returns a handle.
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users").unwrap(); let job = users.delete_async("{\"user_id\":\"1\"}", |res| { println!("{:?}", res); }); job.join();
pub fn update(&self, data: &str) -> Result<Response, RequestError>
[src]
Update data
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let users = _firebase.at("users/user1").unwrap(); users.update("{\"username\":\"new_user_name\"}").unwrap();
pub fn update_async<S, F>(&self, data: S, callback: F) -> JoinHandle<()> where
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
[src]
F: Fn(Result<Response, RequestError>) + Send + 'static,
S: Into<String>,
Asynchronous method for update. Takes a callback function and returns a handle.
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users/user1").unwrap(); let job = users.update_async("{\"username\":\"new_username\"}", |res| { println!("{:?}", res); }); job.join();
pub fn with_params(&self) -> FirebaseParams
[src]
Filter, Sort, Limit and Format Firebase data !That can useable with GET method
Examples
let _firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); let mut users = _firebase.at("users/user1").unwrap(); let order = users.with_params().order_by("user_id").get(); // Chaining can also be used. let order = users.with_params().order_by("user_id").limit_to_first(10).get(); let res = order.get().unwrap();
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Firebase
impl Send for Firebase
impl Sync for Firebase
impl Unpin for Firebase
impl UnwindSafe for Firebase
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,