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)]
14pub struct HelloWorldRequest {}
15
16/// HelloWorldResponse returns the fixed test-provider message.
17///
18/// Native message type for `gestalt.provider.v1.HelloWorldResponse`.
19#[derive(Clone, Debug, Default, PartialEq)]
20pub struct HelloWorldResponse {
21    /// The `message` field.
22    pub message: String,
23}
24
25/// Test models a minimal provider-kind-specific protocol used to verify new
26/// provider kind registration and lifecycle wiring.
27///
28/// Client for the `gestalt.provider.v1.Test` service.
29pub struct Test {
30    inner: v1::test_client::TestClient<tonic::transport::Channel>,
31    timeout: Option<std::time::Duration>,
32}
33
34impl Test {
35    /// Creates a client over an established channel.
36    pub fn new(channel: tonic::transport::Channel) -> Self {
37        Self {
38            inner: v1::test_client::TestClient::new(channel),
39            timeout: None,
40        }
41    }
42
43    /// Sets a deadline applied to every unary call; calls that run past it
44    /// fail with DEADLINE_EXCEEDED. Streaming calls are unaffected.
45    pub fn with_timeout(mut self, timeout: std::time::Duration) -> Self {
46        self.timeout = Some(timeout);
47        self
48    }
49
50    /// Calls `gestalt.provider.v1.Test.HelloWorld`.
51    pub async fn hello_world(
52        &mut self,
53        request: HelloWorldRequest,
54    ) -> Result<String, GestaltError> {
55        let mut tonic_request = tonic::Request::new(to_wire_hello_world_request(request));
56        if let Some(timeout) = self.timeout {
57            tonic_request.set_timeout(timeout);
58        }
59        let response = from_wire_hello_world_response(
60            self.inner.hello_world(tonic_request).await?.into_inner(),
61        );
62        Ok(response.message)
63    }
64
65    /// Calls `gestalt.provider.v1.Test.HelloWorld` with the full request and response messages.
66    pub async fn hello_world_raw(
67        &mut self,
68        request: HelloWorldRequest,
69    ) -> Result<HelloWorldResponse, GestaltError> {
70        let mut tonic_request = tonic::Request::new(to_wire_hello_world_request(request));
71        if let Some(timeout) = self.timeout {
72            tonic_request.set_timeout(timeout);
73        }
74        let response = self.inner.hello_world(tonic_request).await?;
75        Ok(from_wire_hello_world_response(response.into_inner()))
76    }
77}