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

Configure a connection to Google Cloud Storage using the specified credentials.

Example

let gcs = GoogleCloudStorageBuilder::new()
 .with_service_account_path(SERVICE_ACCOUNT_PATH)
 .with_bucket_name(BUCKET_NAME)
 .build();

Implementations§

source§

impl GoogleCloudStorageBuilder

source

pub fn new() -> Self

Create a new GoogleCloudStorageBuilder with default values.

source

pub fn from_env() -> Self

Create an instance of GoogleCloudStorageBuilder with values pre-populated from environment variables.

Variables extracted from environment:

  • GOOGLE_SERVICE_ACCOUNT: location of service account file
  • GOOGLE_SERVICE_ACCOUNT_PATH: (alias) location of service account file
  • SERVICE_ACCOUNT: (alias) location of service account file
  • GOOGLE_SERVICE_ACCOUNT_KEY: JSON serialized service account key
  • GOOGLE_BUCKET: bucket name
  • GOOGLE_BUCKET_NAME: (alias) bucket name
Example
use object_store::gcp::GoogleCloudStorageBuilder;

let gcs = GoogleCloudStorageBuilder::from_env()
    .with_bucket_name("foo")
    .build();
source

pub fn with_url(self, url: impl Into<String>) -> Self

Parse available connection info form a well-known storage URL.

The supported url schemes are:

  • gs://<bucket>/<path>

Note: Settings derived from the URL will override any others set on this builder

Example
use object_store::gcp::GoogleCloudStorageBuilder;

let gcs = GoogleCloudStorageBuilder::from_env()
    .with_url("gs://bucket/path")
    .build();
source

pub fn try_with_option(
self,
key: impl AsRef<str>,
value: impl Into<String>
) -> Result<Self>

Set an option on the builder via a key - value pair.

source

pub fn try_with_options<I: IntoIterator<Item = (impl AsRef<str>, impl Into<String>)>>(
self,
options: I
) -> Result<Self>

Hydrate builder from key value pairs

source

pub fn with_bucket_name(self, bucket_name: impl Into<String>) -> Self

Set the bucket name (required)

source

pub fn with_service_account_path(
self,
service_account_path: impl Into<String>
) -> Self

Set the path to the service account file.

This or GoogleCloudStorageBuilder::with_service_account_key must be set.

Example "/tmp/gcs.json".

Example contents of gcs.json:

{
   "gcs_base_url": "https://localhost:4443",
   "disable_oauth": true,
   "client_email": "",
   "private_key": ""
}
source

pub fn with_service_account_key(self, service_account: impl Into<String>) -> Self

Set the service account key. The service account must be in the JSON format.

This or GoogleCloudStorageBuilder::with_service_account_path must be set.

source

pub fn with_application_credentials(
self,
application_credentials_path: impl Into<String>
) -> Self

Set the path to the application credentials file.

https://cloud.google.com/docs/authentication/provide-credentials-adc

source

pub fn with_retry(self, retry_config: RetryConfig) -> Self

Set the retry configuration

source

pub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self

Set the proxy_url to be used by the underlying client

source

pub fn with_client_options(self, options: ClientOptions) -> Self

Sets the client options, overriding any already set

source

pub fn build(self) -> Result<GoogleCloudStorage>

Configure a connection to Google Cloud Storage, returning a new GoogleCloudStorage and consuming self

Trait Implementations§

source§

impl Clone for GoogleCloudStorageBuilder

source§

fn clone(&self) -> GoogleCloudStorageBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GoogleCloudStorageBuilder

source§

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

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

impl Default for GoogleCloudStorageBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,

§

fn vzip(self) -> V

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