1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ProductTag {
4 #[prost(uint32, tag = "1")]
5 pub id: u32,
6 #[prost(string, tag = "2")]
7 pub name: ::prost::alloc::string::String,
8}
9#[derive(Clone, PartialEq, ::prost::Message)]
10pub struct ProductCreateRequest {
11 #[prost(string, tag = "1")]
12 pub title: ::prost::alloc::string::String,
13 #[prost(string, tag = "2")]
14 pub description: ::prost::alloc::string::String,
15 #[prost(string, tag = "3")]
16 pub sku: ::prost::alloc::string::String,
17 #[prost(uint32, tag = "4")]
18 pub price: u32,
19 #[prost(string, tag = "5")]
20 pub currency_code: ::prost::alloc::string::String,
21 #[prost(message, repeated, tag = "6")]
22 pub tags: ::prost::alloc::vec::Vec<ProductTag>,
23 #[prost(bool, tag = "7")]
24 pub ar_enabled: bool,
25}
26#[derive(Clone, Copy, PartialEq, ::prost::Message)]
27pub struct ProductCreateResponse {}
28pub mod products_service_client {
30 #![allow(
31 unused_variables,
32 dead_code,
33 missing_docs,
34 clippy::wildcard_imports,
35 clippy::let_unit_value,
36 )]
37 use tonic::codegen::*;
38 use tonic::codegen::http::Uri;
39 #[derive(Debug, Clone)]
40 pub struct ProductsServiceClient<T> {
41 inner: tonic::client::Grpc<T>,
42 }
43 impl ProductsServiceClient<tonic::transport::Channel> {
44 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
46 where
47 D: TryInto<tonic::transport::Endpoint>,
48 D::Error: Into<StdError>,
49 {
50 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
51 Ok(Self::new(conn))
52 }
53 }
54 impl<T> ProductsServiceClient<T>
55 where
56 T: tonic::client::GrpcService<tonic::body::Body>,
57 T::Error: Into<StdError>,
58 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
59 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
60 {
61 pub fn new(inner: T) -> Self {
62 let inner = tonic::client::Grpc::new(inner);
63 Self { inner }
64 }
65 pub fn with_origin(inner: T, origin: Uri) -> Self {
66 let inner = tonic::client::Grpc::with_origin(inner, origin);
67 Self { inner }
68 }
69 pub fn with_interceptor<F>(
70 inner: T,
71 interceptor: F,
72 ) -> ProductsServiceClient<InterceptedService<T, F>>
73 where
74 F: tonic::service::Interceptor,
75 T::ResponseBody: Default,
76 T: tonic::codegen::Service<
77 http::Request<tonic::body::Body>,
78 Response = http::Response<
79 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
80 >,
81 >,
82 <T as tonic::codegen::Service<
83 http::Request<tonic::body::Body>,
84 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
85 {
86 ProductsServiceClient::new(InterceptedService::new(inner, interceptor))
87 }
88 #[must_use]
93 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
94 self.inner = self.inner.send_compressed(encoding);
95 self
96 }
97 #[must_use]
99 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
100 self.inner = self.inner.accept_compressed(encoding);
101 self
102 }
103 #[must_use]
107 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
108 self.inner = self.inner.max_decoding_message_size(limit);
109 self
110 }
111 #[must_use]
115 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
116 self.inner = self.inner.max_encoding_message_size(limit);
117 self
118 }
119 pub async fn product_create(
120 &mut self,
121 request: impl tonic::IntoRequest<super::ProductCreateRequest>,
122 ) -> std::result::Result<
123 tonic::Response<super::ProductCreateResponse>,
124 tonic::Status,
125 > {
126 self.inner
127 .ready()
128 .await
129 .map_err(|e| {
130 tonic::Status::unknown(
131 format!("Service was not ready: {}", e.into()),
132 )
133 })?;
134 let codec = tonic::codec::ProstCodec::default();
135 let path = http::uri::PathAndQuery::from_static(
136 "/products.v1.ProductsService/ProductCreate",
137 );
138 let mut req = request.into_request();
139 req.extensions_mut()
140 .insert(GrpcMethod::new("products.v1.ProductsService", "ProductCreate"));
141 self.inner.unary(req, path, codec).await
142 }
143 }
144}
145pub mod products_service_server {
147 #![allow(
148 unused_variables,
149 dead_code,
150 missing_docs,
151 clippy::wildcard_imports,
152 clippy::let_unit_value,
153 )]
154 use tonic::codegen::*;
155 #[async_trait]
157 pub trait ProductsService: std::marker::Send + std::marker::Sync + 'static {
158 async fn product_create(
159 &self,
160 request: tonic::Request<super::ProductCreateRequest>,
161 ) -> std::result::Result<
162 tonic::Response<super::ProductCreateResponse>,
163 tonic::Status,
164 >;
165 }
166 #[derive(Debug)]
167 pub struct ProductsServiceServer<T> {
168 inner: Arc<T>,
169 accept_compression_encodings: EnabledCompressionEncodings,
170 send_compression_encodings: EnabledCompressionEncodings,
171 max_decoding_message_size: Option<usize>,
172 max_encoding_message_size: Option<usize>,
173 }
174 impl<T> ProductsServiceServer<T> {
175 pub fn new(inner: T) -> Self {
176 Self::from_arc(Arc::new(inner))
177 }
178 pub fn from_arc(inner: Arc<T>) -> Self {
179 Self {
180 inner,
181 accept_compression_encodings: Default::default(),
182 send_compression_encodings: Default::default(),
183 max_decoding_message_size: None,
184 max_encoding_message_size: None,
185 }
186 }
187 pub fn with_interceptor<F>(
188 inner: T,
189 interceptor: F,
190 ) -> InterceptedService<Self, F>
191 where
192 F: tonic::service::Interceptor,
193 {
194 InterceptedService::new(Self::new(inner), interceptor)
195 }
196 #[must_use]
198 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
199 self.accept_compression_encodings.enable(encoding);
200 self
201 }
202 #[must_use]
204 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
205 self.send_compression_encodings.enable(encoding);
206 self
207 }
208 #[must_use]
212 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
213 self.max_decoding_message_size = Some(limit);
214 self
215 }
216 #[must_use]
220 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
221 self.max_encoding_message_size = Some(limit);
222 self
223 }
224 }
225 impl<T, B> tonic::codegen::Service<http::Request<B>> for ProductsServiceServer<T>
226 where
227 T: ProductsService,
228 B: Body + std::marker::Send + 'static,
229 B::Error: Into<StdError> + std::marker::Send + 'static,
230 {
231 type Response = http::Response<tonic::body::Body>;
232 type Error = std::convert::Infallible;
233 type Future = BoxFuture<Self::Response, Self::Error>;
234 fn poll_ready(
235 &mut self,
236 _cx: &mut Context<'_>,
237 ) -> Poll<std::result::Result<(), Self::Error>> {
238 Poll::Ready(Ok(()))
239 }
240 fn call(&mut self, req: http::Request<B>) -> Self::Future {
241 match req.uri().path() {
242 "/products.v1.ProductsService/ProductCreate" => {
243 #[allow(non_camel_case_types)]
244 struct ProductCreateSvc<T: ProductsService>(pub Arc<T>);
245 impl<
246 T: ProductsService,
247 > tonic::server::UnaryService<super::ProductCreateRequest>
248 for ProductCreateSvc<T> {
249 type Response = super::ProductCreateResponse;
250 type Future = BoxFuture<
251 tonic::Response<Self::Response>,
252 tonic::Status,
253 >;
254 fn call(
255 &mut self,
256 request: tonic::Request<super::ProductCreateRequest>,
257 ) -> Self::Future {
258 let inner = Arc::clone(&self.0);
259 let fut = async move {
260 <T as ProductsService>::product_create(&inner, request)
261 .await
262 };
263 Box::pin(fut)
264 }
265 }
266 let accept_compression_encodings = self.accept_compression_encodings;
267 let send_compression_encodings = self.send_compression_encodings;
268 let max_decoding_message_size = self.max_decoding_message_size;
269 let max_encoding_message_size = self.max_encoding_message_size;
270 let inner = self.inner.clone();
271 let fut = async move {
272 let method = ProductCreateSvc(inner);
273 let codec = tonic::codec::ProstCodec::default();
274 let mut grpc = tonic::server::Grpc::new(codec)
275 .apply_compression_config(
276 accept_compression_encodings,
277 send_compression_encodings,
278 )
279 .apply_max_message_size_config(
280 max_decoding_message_size,
281 max_encoding_message_size,
282 );
283 let res = grpc.unary(method, req).await;
284 Ok(res)
285 };
286 Box::pin(fut)
287 }
288 _ => {
289 Box::pin(async move {
290 let mut response = http::Response::new(
291 tonic::body::Body::default(),
292 );
293 let headers = response.headers_mut();
294 headers
295 .insert(
296 tonic::Status::GRPC_STATUS,
297 (tonic::Code::Unimplemented as i32).into(),
298 );
299 headers
300 .insert(
301 http::header::CONTENT_TYPE,
302 tonic::metadata::GRPC_CONTENT_TYPE,
303 );
304 Ok(response)
305 })
306 }
307 }
308 }
309 }
310 impl<T> Clone for ProductsServiceServer<T> {
311 fn clone(&self) -> Self {
312 let inner = self.inner.clone();
313 Self {
314 inner,
315 accept_compression_encodings: self.accept_compression_encodings,
316 send_compression_encodings: self.send_compression_encodings,
317 max_decoding_message_size: self.max_decoding_message_size,
318 max_encoding_message_size: self.max_encoding_message_size,
319 }
320 }
321 }
322 pub const SERVICE_NAME: &str = "products.v1.ProductsService";
324 impl<T> tonic::server::NamedService for ProductsServiceServer<T> {
325 const NAME: &'static str = SERVICE_NAME;
326 }
327}