Struct tame_gcs::objects::Object

source ·
pub struct Object { /* private fields */ }
Expand description

Helper struct used to collate all of the operations available for Objects Additionally, it can also be used to specify a custom authority.

Implementations§

source§

impl Object

source

pub fn delete<'a, OID>( &self, id: &OID, optional: Option<DeleteObjectOptional<'_>> ) -> Result<Request<Empty>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.

Required IAM Permissions: storage.objects.delete

Complete API documentation

source§

impl Object

source

pub fn download<'a, OID>( &self, id: &OID, optional: Option<DownloadObjectOptional<'_>> ) -> Result<Request<Empty>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Downloads an object

Required IAM Permissions: storage.objects.get, storage.objects.getIamPolicy*

Complete API Documentation

source§

impl Object

source

pub fn get<'a, OID>( &self, id: &OID, optional: Option<GetObjectOptional<'_>> ) -> Result<Request<Empty>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Gets an object’s metadata

Required IAM Permissions: storage.objects.get, storage.objects.getIamPolicy*

Complete API Documentation

source§

impl Object

source

pub fn insert_multipart<B>( &self, bucket: &BucketName<'_>, content: B, length: u64, metadata: &Metadata, optional: Option<InsertObjectOptional<'_>> ) -> Result<Request<Multipart<B>>, Error>

Stores a new object and metadata.

  • Maximum file size: 5TB
  • Accepted Media MIME types: */*

This method differs from insert_simple in that it performs a multipart upload which allows you specify both the object data and its metadata in a single request, instead of having to do an additional request to set the metadata.

NOTE: You must specify the name field in the metadata provided to this function with a valid object name. Only the content_type specified in metadata will be used, the content_type in optional will be ignored.

Required IAM Permissions: storage.objects.create, storage.objects.delete

Note: storage.objects.delete is only needed if an object with the same name already exists.

Complete API Documentation

source§

impl Object

source

pub fn resumable_insert_init<'a, OID>( &self, id: &OID, content_type: Option<&str> ) -> Result<Request<()>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Initiates a resumable upload session.

  • Accepted Media MIME types: */*

Note: A resumable upload must be completed within a week of being initiated.

CAUTION: Be careful when sharing the resumable session URI, because it can be used by anyone to upload data to the target bucket without any further authentication.

Required IAM Permissions: storage.objects.create, storage.objects.delete

Note: storage.objects.delete is only needed if an object with the same name already exists.

Complete API Documentation

source

pub fn resumable_cancel(session: ResumableSession) -> Result<Request<()>, Error>

Cancels an incomplete resumable upload and prevent any further action for session_uri, which should have been obtained using [Object::init_resumable_insert]

Complete API Documentation

source

pub fn resumable_append<B>( session: ResumableSession, content: B, length: u64 ) -> Result<Request<B>, Error>

Performs resumable upload to the specified session_uri, which should have been obtained using [Object::init_resumable_insert]

  • Maximum total object size: 5TB

There are two ways to upload the object’s data:

  • For single chunk upload, set length to the total size of the object.
  • For multiple chunks upload, set length to the size of current chunk that is being uploaded and Content-Range header as bytes CHUNK_FIRST_BYTE-CHUNK_LAST_BYTE/TOTAL_OBJECT_SIZE where:
    • CHUNK_FIRST_BYTE is the starting byte in the overall object that the chunk you’re uploading contains.
    • CHUNK_LAST_BYTE is the ending byte in the overall object that the chunk you’re uploading contains.
    • TOTAL_OBJECT_SIZE is the total size of the object you are uploading.

NOTE: length should be a multiple of 256KiB, unless it’s the last chunk. If not, the server will not accept all bytes sent in the request. Also, it is recommended to use at least 8MiB.

Complete API Documentation

source§

impl Object

source

pub fn insert_simple<'a, OID, B>( &self, id: &OID, content: B, length: u64, optional: Option<InsertObjectOptional<'_>> ) -> Result<Request<B>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Stores a new object and metadata.

  • Maximum file size: 5TB
  • Accepted Media MIME types: */*

Required IAM Permissions: storage.objects.create, storage.objects.delete

Note: storage.objects.delete is only needed if an object with the same name already exists.

Complete API Documentation

source§

impl Object

source

pub fn list( &self, bucket: &BucketName<'_>, optional: Option<ListOptional<'_>> ) -> Result<Request<Empty>, Error>

Retrieves a list of objects matching the criteria.

Required IAM Permissions: storage.objects.list, storage.objects.getIamPolicy*

Complete API Documentation

source§

impl Object

source

pub fn patch<'a, OID>( &self, id: &OID, metadata: &Metadata, optional: Option<PatchObjectOptional<'_>> ) -> Result<Request<Cursor<Vec<u8>>>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Updates a data blob’s associated metadata.

Required IAM Permissions: storage.objects.get, storage.objects.update

Complete API documentation

source§

impl Object

source

pub fn rewrite<'a, OID>( &self, source: &OID, destination: &OID, rewrite_token: Option<String>, metadata: Option<&Metadata>, optional: Option<RewriteObjectOptional<'_>> ) -> Result<Request<Cursor<Vec<u8>>>, Error>
where OID: ObjectIdentifier<'a> + ?Sized,

Rewrites a source object to a destination object. Optionally overrides metadata.

Required IAM Permissions:

  • storage.objects.create (for the destination bucket)
  • storage.objects.delete (for the destination bucket)
  • storage.objects.get (for the source bucket)

Complete API Documentation

source§

impl Object

source

pub fn with_authority(authority: Authority) -> Self

Supplies a custom HTTP authority, allowing a GCS host other than the standard storage.googleapis.com to be used

Trait Implementations§

source§

impl Clone for Object

source§

fn clone(&self) -> Object

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 Object

source§

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

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

impl Default for Object

source§

fn default() -> Self

Defaults to the standard GCS location storage.googleapis.com

Auto Trait Implementations§

§

impl !Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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, 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> ToOwned for T
where 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 T
where 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 T
where 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.