google-cloud-storage 1.11.0

Google Cloud Client Libraries for Rust - Storage
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
use crate::Result;

/// Implements a [StorageControl](super::stub::StorageControl) decorator for logging and tracing.
#[derive(Clone, Debug)]
pub struct StorageControl<T>
where
    T: super::stub::StorageControl + std::fmt::Debug + Send + Sync,
{
    inner: T,
    duration: gaxi::observability::DurationMetric,
}

impl<T> StorageControl<T>
where
    T: super::stub::StorageControl + std::fmt::Debug + Send + Sync,
{
    pub fn new(inner: T) -> Self {
        Self {
            inner,
            duration: gaxi::observability::DurationMetric::new(&info::INSTRUMENTATION_CLIENT_INFO),
        }
    }
}

impl<T> super::stub::StorageControl for StorageControl<T>
where
    T: super::stub::StorageControl + std::fmt::Debug + Send + Sync,
{
    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn delete_bucket(
        &self,
        req: crate::model::DeleteBucketRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<()>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::delete_bucket",
            self.inner.delete_bucket(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_bucket(
        &self,
        req: crate::model::GetBucketRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Bucket>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::get_bucket",
            self.inner.get_bucket(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn create_bucket(
        &self,
        req: crate::model::CreateBucketRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Bucket>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::create_bucket",
            self.inner.create_bucket(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_buckets(
        &self,
        req: crate::model::ListBucketsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListBucketsResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::list_buckets",
            self.inner.list_buckets(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn lock_bucket_retention_policy(
        &self,
        req: crate::model::LockBucketRetentionPolicyRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Bucket>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::lock_bucket_retention_policy",
            self.inner.lock_bucket_retention_policy(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn update_bucket(
        &self,
        req: crate::model::UpdateBucketRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Bucket>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::update_bucket",
            self.inner.update_bucket(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn compose_object(
        &self,
        req: crate::model::ComposeObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Object>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::compose_object",
            self.inner.compose_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn delete_object(
        &self,
        req: crate::model::DeleteObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<()>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::delete_object",
            self.inner.delete_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn restore_object(
        &self,
        req: crate::model::RestoreObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Object>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::restore_object",
            self.inner.restore_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_object(
        &self,
        req: crate::model::GetObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Object>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::get_object",
            self.inner.get_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn update_object(
        &self,
        req: crate::model::UpdateObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Object>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::update_object",
            self.inner.update_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_objects(
        &self,
        req: crate::model::ListObjectsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListObjectsResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::list_objects",
            self.inner.list_objects(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn rewrite_object(
        &self,
        req: crate::model::RewriteObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::RewriteResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::rewrite_object",
            self.inner.rewrite_object(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn move_object(
        &self,
        req: crate::model::MoveObjectRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Object>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::StorageControl::move_object",
            self.inner.move_object(req, options));
        pending.await
    }
}

pub(crate) mod info {
    const NAME: &str = env!("CARGO_PKG_NAME");
    const VERSION: &str = env!("CARGO_PKG_VERSION");
    pub(crate) static INSTRUMENTATION_CLIENT_INFO: std::sync::LazyLock<
        gaxi::options::InstrumentationClientInfo,
    > = std::sync::LazyLock::new(|| {
        let mut info = gaxi::options::InstrumentationClientInfo::default();
        info.service_name = "storage";
        info.client_version = VERSION;
        info.client_artifact = NAME;
        info.default_host = "storage";
        info
    });
}