pub struct GcsStorage { /* private fields */ }storage-azure or storage-gcs or storage-local or storage-s3 only.Expand description
Google Cloud Storage, through its JSON API and the outbound HTTP client
(crate::http_client::Client) — no Google SDK.
Requests carry an OAuth 2.0 access token, found as Google’s client
libraries find Application Default Credentials: RWS_GCS_ACCESS_TOKEN,
then the file in GOOGLE_APPLICATION_CREDENTIALS (a service account key
or authorized_user), then gcloud’s
application_default_credentials.json, then the metadata server
(Compute Engine, GKE Workload Identity, Cloud Run). Tokens are cached and
refreshed before they expire. RWS_GCS_CREDENTIAL_SOURCE=token|file|metadata|none
picks one; none sends no credentials (emulators).
Implementations§
Source§impl GcsStorage
impl GcsStorage
pub fn new(config: GcsConfig) -> GcsStorage
Sourcepub fn from_env() -> Result<GcsStorage, StorageError>
pub fn from_env() -> Result<GcsStorage, StorageError>
Shortcut for GcsStorage::new(GcsConfig::from_env()?).
Trait Implementations§
Source§impl Storage for GcsStorage
impl Storage for GcsStorage
Source§fn url(&self, key: &str) -> String
fn url(&self, key: &str) -> String
{endpoint}/{bucket}/{key} — the object’s public URL
(https://storage.googleapis.com/...), which works for objects
readable by allUsers; private ones need a signed URL.
Source§fn put(
&self,
key: &str,
data: &[u8],
content_type: &str,
) -> Result<String, StorageError>
fn put( &self, key: &str, data: &[u8], content_type: &str, ) -> Result<String, StorageError>
data under key, overwriting any existing object at that key.
Returns the key that was stored (backends that normalize or namespace
keys may return a different string than the one passed in).Source§fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>
fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>
key.Source§fn delete(&self, key: &str) -> Result<(), StorageError>
fn delete(&self, key: &str) -> Result<(), StorageError>
key. Backends generally treat
deleting a missing key as a no-op success, matching S3’s semantics.Source§fn put_stream(
&self,
key: &str,
reader: &mut dyn Read,
content_type: &str,
) -> Result<String, StorageError>
fn put_stream( &self, key: &str, reader: &mut dyn Read, content_type: &str, ) -> Result<String, StorageError>
reader yields under key — for a body too large
to hold in memory, e.g. a streamed upload (Request::body read as a
stream, #31). LocalStorage writes as it reads and S3Storage
uploads in parts (S3 multipart upload), so memory stays at one part;
the default reads everything first and calls Storage::put.Auto Trait Implementations§
impl !Freeze for GcsStorage
impl RefUnwindSafe for GcsStorage
impl Send for GcsStorage
impl Sync for GcsStorage
impl Unpin for GcsStorage
impl UnsafeUnpin for GcsStorage
impl UnwindSafe for GcsStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.