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

Represents the Firebase Storage service.

Implementations§

source§

impl<'a> Storage<'a>

source

pub fn new(app: &'a App<'a>) -> Self

Creates a new instance of Firebase Storage.

source

pub async fn add_firebase(&self) -> Result<Bucket, StatusCode>

Links a Google Cloud Storage bucket to the Firebase project.

Examples
let storage = Storage::new(app);
let result = storage.add_firebase().await?;
println!("Bucket name: {}", result.name);
source

pub async fn remove_firebase(&self) -> Result<(), StatusCode>

Unlinks a linked Google Cloud Storage bucket from the Firebase project.

Examples
let storage = Storage::new(app);
storage.remove_firebase().await?;
println!("Bucket unlinked successfully.");
source

pub async fn list( &self, page_token: &str, page_size: u8 ) -> Result<Buckets, StatusCode>

Lists the linked storage buckets for the Firebase project.

Arguments
  • page_token - The page token for pagination.
  • page_size - The maximum number of buckets to include in a single page.
Examples
let storage = Storage::new(app);
let result = storage.list("", 10).await?;

println!("Buckets:");
for bucket in result.buckets {
    println!("Bucket name: {}", bucket.name);
}

if let Some(next_page_token) = result.next_page_token {
    println!("Next page token: {}", next_page_token);
}
source

pub async fn get(&self, name: &str) -> Result<Buckets, StatusCode>

Gets a single linked storage bucket from the Firebase project.

Arguments
  • name - The name of the storage bucket.
Examples
let storage = Storage::new(app);
let result = storage.get("my-bucket").await?;

println!("Buckets:");
for bucket in result.buckets {
    println!("Bucket name: {}", bucket.name);
}

if let Some(next_page_token) = result.next_page_token {
    println!("Next page token: {}", next_page_token);
}

Trait Implementations§

source§

impl RequestDefaults<'_> for Storage<'_>

source§

fn default_post_requestor(&self, endpoint: &str, _: &str) -> RequestBuilder

Modifies the provided RequestBuilder with default settings for post request. Read more
source§

fn default_get_requestor( &self, _: &str, _: ParameterHashMap<'_> ) -> RequestBuilder

Modifies the provided RequestBuilder with default settings for get request. Read more
source§

fn default_headers(&self, request_builder: RequestBuilder) -> RequestBuilder

Modifies the provided RequestBuilder with default headers. Read more
source§

fn default_parameters( &self, _request_builder: RequestBuilder ) -> HashMap<&str, Option<&str>, RandomState>

Modifies the provided RequestBuilder with default parameters. Read more
source§

impl RequestHandler<'_> for Storage<'_>

source§

const BASE_URL: &'static str = "https://firebasestorage.googleapis.com/v1beta"

The base URL for the requests.
source§

const API_KEY: Option<&'static str> = Some("apiKey")

The API key as string used for authentication.
source§

fn join_endpoints(endpoint: &str) -> String

Joins the given endpoint with the base URL. Read more
source§

fn parameters<Function>( &self, function: Function ) -> HashMap<&'a str, Option<&'a str>, RandomState>where Function: FnOnce(&mut HashMap<&'a str, Option<&'a str>, RandomState>),

Builds the parameter hashmap using the given function. Read more
source§

fn request<'life0, 'async_trait, T>( &'life0 self, request_builder: RequestBuilder ) -> Pin<Box<dyn Future<Output = Result<T, StatusCode>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: for<'de> Deserialize<'de> + 'async_trait, Self: Sync + 'async_trait,

Sends an HTTP request with the given RequestBuilder, and returns the parsed response. Read more

Auto Trait Implementations§

§

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

§

impl<'a> Send for Storage<'a>

§

impl<'a> Sync for Storage<'a>

§

impl<'a> Unpin for Storage<'a>

§

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

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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