Struct Node

Source
pub struct Node<'a> { /* private fields */ }
Expand description

Represents a node in the Firebase Realtime Database.

Nodes are used to traverse the database hierarchy and perform operations at specific paths. Each node maintains its full path and can create child nodes or perform CRUD operations.

The path is built incrementally using the builder pattern, allowing for fluent API usage.

§Example

use firebase_rtdb::{FirebaseRTDB, RtdbError};

 async fn example() -> Result<(), RtdbError> {
    let mut db = FirebaseRTDB::new_from_jwt("https://your-project.firebaseio.com", "your-jwt-token", "your-api-key").await?;
    let mut root = db.root().await?;
    let users = root
        .child("users")
        .child("user123")
        .child("profile");
    Ok(())
}

Implementations§

Source§

impl Node<'_>

Source

pub fn child<T: AsRef<str>>(&mut self, child: T) -> &mut Self

Creates a new child node at the specified path.

§Arguments
  • child - The name of the child node to create
§Returns

Returns a mutable reference to the new child node

Source

pub fn final_node<T: AsRef<str>>(&mut self, node: T) -> &Self

Finalizes the node path with a last segment.

Similar to child() but returns an immutable reference, useful for immediately performing an operation.

Source

pub async fn get(&self) -> Result<String, RtdbError>

Retrieves data at the current node path.

Performs a GET request to fetch the current value at this database location.

Source

pub async fn put<T: Serialize>(&self, input: T) -> Result<String, RtdbError>

Writes data to the current node path.

Performs a PUT request to set the value at this database location. The input must be serializable to JSON.

Source

pub async fn post<T: Serialize>(&self, input: T) -> Result<String, RtdbError>

Creates a new child with a unique key.

Performs a POST request to create a new child with a Firebase-generated key and the provided data.

Source

pub async fn patch<T: Serialize>(&self, input: T) -> Result<String, RtdbError>

Updates specific fields at the current path.

Performs a PATCH request to update only the specified fields while leaving others unchanged.

Source

pub async fn delete(&self) -> Result<String, RtdbError>

Removes data at the current path.

Performs a DELETE request to remove all data at this location.

Auto Trait Implementations§

§

impl<'a> Freeze for Node<'a>

§

impl<'a> !RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>

§

impl<'a> Sync for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> !UnwindSafe for Node<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

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 T
where U: From<T>,

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,