RewriteObjectExt

Trait RewriteObjectExt 

Source
pub trait RewriteObjectExt {
    // Required method
    fn rewrite_until_done<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<Object>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

An extension trait for RewriteObject to provide a convenient way to poll a rewrite operation until it is complete.

Required Methods§

Source

fn rewrite_until_done<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<Object>> + Send + 'async_trait>>
where Self: 'async_trait,

Sends the request and polls the operation until it is complete.

This helper function simplifies the process of handling a StorageControl::rewrite_object operation, which may require multiple requests to complete. It automatically handles the logic of sending the rewrite_token from one response in the next request.

For more details on this loop, see the “Rewriting objects” section of the user guide: https://googleapis.github.io/google-cloud-rust/storage/rewrite_object.html

§Example
const SOURCE_NAME: &str = "object-to-copy";
const DEST_NAME: &str = "copied-object";
let source_bucket_id = "source-bucket";
let dest_bucket_id = "dest-bucket";
let copied = client
    .rewrite_object()
    .set_source_bucket(format!("projects/_/buckets/{source_bucket_id}"))
    .set_source_object(SOURCE_NAME)
    .set_destination_bucket(format!("projects/_/buckets/{dest_bucket_id}"))
    .set_destination_name(DEST_NAME)
    .rewrite_until_done()
    .await?;

Implementors§