google-developers-knowledge-v1 1.1.0

Google Cloud Client Libraries for Rust - Developer Knowledge API
Documentation
// Copyright 2026 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 [DeveloperKnowledge](super::stub::DeveloperKnowledge) decorator for logging and tracing.
#[derive(Clone, Debug)]
pub struct DeveloperKnowledge<T>
where
    T: super::stub::DeveloperKnowledge + std::fmt::Debug + Send + Sync,
{
    inner: T,
    duration: gaxi::observability::DurationMetric,
}

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

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

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

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn answer_query(
        &self,
        req: crate::model::AnswerQueryRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::AnswerQueryResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::DeveloperKnowledge::answer_query",
            self.inner.answer_query(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 = "developerknowledge";
        info.client_version = VERSION;
        info.client_artifact = NAME;
        info.default_host = "developerknowledge";
        info
    });
}