Skip to main content

gestalt/
test.rs

1// Code generated by sdkgen. DO NOT EDIT.
2
3//! Generated native types and clients for test.proto.
4
5use crate::codec::test::{from_wire_hello_world_response, to_wire_hello_world_request};
6use crate::generated::v1;
7use crate::rpc_support::GestaltError;
8
9/// HelloWorldRequest carries no input fields. It exists to exercise the
10/// provider-kind-specific request/response path.
11///
12/// Native message type for `gestalt.provider.v1.HelloWorldRequest`.
13#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct HelloWorldRequest {}
16
17/// HelloWorldResponse returns the fixed test-provider message.
18///
19/// Native message type for `gestalt.provider.v1.HelloWorldResponse`.
20#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
21#[serde(rename_all = "camelCase")]
22pub struct HelloWorldResponse {
23    /// The `message` field.
24    pub message: String,
25}
26
27/// Test models a minimal provider-kind-specific protocol used to verify new
28/// provider kind registration and lifecycle wiring.
29///
30/// Client for the `gestalt.provider.v1.Test` service.
31pub struct Test {
32    inner: v1::test_client::TestClient<tonic::transport::Channel>,
33    timeout: Option<std::time::Duration>,
34}
35
36impl Test {
37    /// Creates a client over an established channel.
38    pub fn new(channel: tonic::transport::Channel) -> Self {
39        Self {
40            inner: v1::test_client::TestClient::new(channel),
41            timeout: None,
42        }
43    }
44
45    /// Sets a deadline applied to every unary call; calls that run past it
46    /// fail with DEADLINE_EXCEEDED. Streaming calls are unaffected.
47    pub fn with_timeout(mut self, timeout: std::time::Duration) -> Self {
48        self.timeout = Some(timeout);
49        self
50    }
51
52    /// Calls `gestalt.provider.v1.Test.HelloWorld`.
53    pub async fn hello_world(
54        &mut self,
55        request: HelloWorldRequest,
56    ) -> Result<String, GestaltError> {
57        let mut tonic_request = tonic::Request::new(to_wire_hello_world_request(request));
58        if let Some(timeout) = self.timeout {
59            tonic_request.set_timeout(timeout);
60        }
61        let response = from_wire_hello_world_response(
62            self.inner.hello_world(tonic_request).await?.into_inner(),
63        );
64        Ok(response.message)
65    }
66
67    /// Calls `gestalt.provider.v1.Test.HelloWorld` with the full request and response messages.
68    pub async fn hello_world_raw(
69        &mut self,
70        request: HelloWorldRequest,
71    ) -> Result<HelloWorldResponse, GestaltError> {
72        let mut tonic_request = tonic::Request::new(to_wire_hello_world_request(request));
73        if let Some(timeout) = self.timeout {
74            tonic_request.set_timeout(timeout);
75        }
76        let response = self.inner.hello_world(tonic_request).await?;
77        Ok(from_wire_hello_world_response(response.into_inner()))
78    }
79}