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