pub struct Firebase { /* private fields */ }
Expand description

Represents an instance of Firebase Realtime Database.

Implementations§

source§

impl Firebase

source

pub fn new(uri: &str) -> Result<Self, UrlParseError>where Self: Sized,

use firebase_rs::Firebase;

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap();
source

pub fn auth(uri: &str, auth_key: &str) -> Result<Self, UrlParseError>where Self: Sized,

use firebase_rs::Firebase;

let firebase = Firebase::auth("https://myfirebase.firebaseio.com", "my_auth_key").unwrap();
source

pub fn base_uri(&self) -> String

use firebase_rs::Firebase;

let uri = "https://myfirebase.firebaseio.com";
let mut firebase = Firebase::new(uri).unwrap();
let endpoint = firebase.at("users");

let base_uri = firebase.base_uri();
let new_base_uri = endpoint.base_uri();

assert_eq!(base_uri, format!("{}/", uri));
assert_eq!(new_base_uri, format!("{}/users.json", uri));
source§

impl Firebase

source

pub fn at(&self, path: &str) -> Self

Returns a new Firebase instance with the base_uri updated to include the given path.

Arguments
  • path - A &str that represents the path to be added to the base URI.
Returns

A new instance of Firebase with the base_uri updated to include the given path.

Panics

If the base_uri cannot be a base URI.

Trait Implementations§

source§

impl Debug for Firebase

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Paramable for Firebase

source§

fn add_param<T>(&self, key: &str, value: T) -> Selfwhere T: ToString,

Adds a parameter to the URL.
source§

fn order_by(&self, key: &str) -> Self

Sets the order of results by the given key.
source§

fn limit_to_first(&self, count: u32) -> Self

Limits the results to the first count items.
source§

fn limit_to_last(&self, count: u32) -> Self

Limits the results to the last count items.
source§

fn start_at(&self, index: u32) -> Self

Starts the results at the item with the given index.
source§

fn end_at(&self, index: u32) -> Self

Ends the results at the item with the given index.
source§

fn equal_to(&self, value: u32) -> Self

Limits the results to items equal to the given value.
source§

fn shallow(&self, flag: bool) -> Self

Sets whether to include shallow items.
source§

fn format(&self) -> Self

Sets the format of the returned data.
source§

impl Requestable for Firebase

source§

fn request<'life0, 'async_trait, Resp>( &'life0 self, method: Method, data: Option<Value> ) -> Pin<Box<dyn Future<Output = Result<Response<Resp>>> + Send + 'async_trait>>where Resp: for<'a> Deserialize<'a> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Sends an HTTP request with a given HTTP method and data and returns a deserialized response. Read more
source§

fn request_generic<'life0, 'async_trait, T>( &'life0 self, method: Method ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where T: Serialize + DeserializeOwned + Debug + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Sends an HTTP request with a given HTTP method and returns a generic deserialized response. Read more
source§

fn set<'life0, 'life1, 'async_trait, T, Resp>( &'life0 self, data: &'life1 T ) -> Pin<Box<dyn Future<Output = Result<Response<Resp>>> + Send + 'async_trait>>where T: Serialize + DeserializeOwned + Debug + Send + Sync + 'async_trait, Resp: for<'a> Deserialize<'a> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn get_as_string<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Response<String>>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait,

source§

fn get<'life0, 'async_trait, T>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where T: Serialize + DeserializeOwned + Debug + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

source§

fn delete<'life0, 'async_trait, Resp>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Response<Resp>>> + Send + 'async_trait>>where Resp: for<'a> Deserialize<'a> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

source§

fn update<'life0, 'life1, 'async_trait, T, Resp>( &'life0 self, data: &'life1 T ) -> Pin<Box<dyn Future<Output = Result<Response<Resp>>> + Send + 'async_trait>>where T: DeserializeOwned + Serialize + Debug + Send + Sync + 'async_trait, Resp: for<'a> Deserialize<'a> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more