1#![allow(
2 unused_variables,
3 dead_code,
4 missing_docs,
5 clippy::wildcard_imports,
6 clippy::let_unit_value
7)]
8use tonic::codegen::*;
9#[async_trait]
11pub trait FileService: std::marker::Send + std::marker::Sync + 'static {
12 async fn create_file(
14 &self,
15 request: tonic::Request<super::CreateFileRequest>,
16 ) -> std::result::Result<tonic::Response<super::CreateFileResponse>, tonic::Status>;
17 async fn list_files(
19 &self,
20 request: tonic::Request<super::ListFilesRequest>,
21 ) -> std::result::Result<tonic::Response<super::ListFilesResponse>, tonic::Status>;
22 async fn get_file(
24 &self,
25 request: tonic::Request<super::GetFileRequest>,
26 ) -> std::result::Result<tonic::Response<super::File>, tonic::Status>;
27 async fn delete_file(
29 &self,
30 request: tonic::Request<super::DeleteFileRequest>,
31 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
32}
33#[derive(Debug)]
35pub struct FileServiceServer<T> {
36 inner: Arc<T>,
37 accept_compression_encodings: EnabledCompressionEncodings,
38 send_compression_encodings: EnabledCompressionEncodings,
39 max_decoding_message_size: Option<usize>,
40 max_encoding_message_size: Option<usize>,
41}
42impl<T> FileServiceServer<T> {
43 pub fn new(inner: T) -> Self {
44 Self::from_arc(Arc::new(inner))
45 }
46 pub fn from_arc(inner: Arc<T>) -> Self {
47 Self {
48 inner,
49 accept_compression_encodings: Default::default(),
50 send_compression_encodings: Default::default(),
51 max_decoding_message_size: None,
52 max_encoding_message_size: None,
53 }
54 }
55 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
56 where
57 F: tonic::service::Interceptor,
58 {
59 InterceptedService::new(Self::new(inner), interceptor)
60 }
61 #[must_use]
63 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
64 self.accept_compression_encodings.enable(encoding);
65 self
66 }
67 #[must_use]
69 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
70 self.send_compression_encodings.enable(encoding);
71 self
72 }
73 #[must_use]
77 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
78 self.max_decoding_message_size = Some(limit);
79 self
80 }
81 #[must_use]
85 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
86 self.max_encoding_message_size = Some(limit);
87 self
88 }
89}
90impl<T, B> tonic::codegen::Service<http::Request<B>> for FileServiceServer<T>
91where
92 T: FileService,
93 B: Body + std::marker::Send + 'static,
94 B::Error: Into<StdError> + std::marker::Send + 'static,
95{
96 type Response = http::Response<tonic::body::Body>;
97 type Error = std::convert::Infallible;
98 type Future = BoxFuture<Self::Response, Self::Error>;
99 fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<std::result::Result<(), Self::Error>> {
100 Poll::Ready(Ok(()))
101 }
102 fn call(&mut self, req: http::Request<B>) -> Self::Future {
103 match req.uri().path() {
104 "/google.ai.generativelanguage.v1beta.FileService/CreateFile" => {
105 #[allow(non_camel_case_types)]
106 struct CreateFileSvc<T: FileService>(pub Arc<T>);
107 impl<T: FileService> tonic::server::UnaryService<super::CreateFileRequest> for CreateFileSvc<T> {
108 type Response = super::CreateFileResponse;
109 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
110 fn call(
111 &mut self,
112 request: tonic::Request<super::CreateFileRequest>,
113 ) -> Self::Future {
114 let inner = Arc::clone(&self.0);
115 let fut =
116 async move { <T as FileService>::create_file(&inner, request).await };
117 Box::pin(fut)
118 }
119 }
120 let accept_compression_encodings = self.accept_compression_encodings;
121 let send_compression_encodings = self.send_compression_encodings;
122 let max_decoding_message_size = self.max_decoding_message_size;
123 let max_encoding_message_size = self.max_encoding_message_size;
124 let inner = self.inner.clone();
125 let fut = async move {
126 let method = CreateFileSvc(inner);
127 let codec = tonic::codec::ProstCodec::default();
128 let mut grpc = tonic::server::Grpc::new(codec)
129 .apply_compression_config(
130 accept_compression_encodings,
131 send_compression_encodings,
132 )
133 .apply_max_message_size_config(
134 max_decoding_message_size,
135 max_encoding_message_size,
136 );
137 let res = grpc.unary(method, req).await;
138 Ok(res)
139 };
140 Box::pin(fut)
141 }
142 "/google.ai.generativelanguage.v1beta.FileService/ListFiles" => {
143 #[allow(non_camel_case_types)]
144 struct ListFilesSvc<T: FileService>(pub Arc<T>);
145 impl<T: FileService> tonic::server::UnaryService<super::ListFilesRequest> for ListFilesSvc<T> {
146 type Response = super::ListFilesResponse;
147 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
148 fn call(
149 &mut self,
150 request: tonic::Request<super::ListFilesRequest>,
151 ) -> Self::Future {
152 let inner = Arc::clone(&self.0);
153 let fut =
154 async move { <T as FileService>::list_files(&inner, request).await };
155 Box::pin(fut)
156 }
157 }
158 let accept_compression_encodings = self.accept_compression_encodings;
159 let send_compression_encodings = self.send_compression_encodings;
160 let max_decoding_message_size = self.max_decoding_message_size;
161 let max_encoding_message_size = self.max_encoding_message_size;
162 let inner = self.inner.clone();
163 let fut = async move {
164 let method = ListFilesSvc(inner);
165 let codec = tonic::codec::ProstCodec::default();
166 let mut grpc = tonic::server::Grpc::new(codec)
167 .apply_compression_config(
168 accept_compression_encodings,
169 send_compression_encodings,
170 )
171 .apply_max_message_size_config(
172 max_decoding_message_size,
173 max_encoding_message_size,
174 );
175 let res = grpc.unary(method, req).await;
176 Ok(res)
177 };
178 Box::pin(fut)
179 }
180 "/google.ai.generativelanguage.v1beta.FileService/GetFile" => {
181 #[allow(non_camel_case_types)]
182 struct GetFileSvc<T: FileService>(pub Arc<T>);
183 impl<T: FileService> tonic::server::UnaryService<super::GetFileRequest> for GetFileSvc<T> {
184 type Response = super::File;
185 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
186 fn call(
187 &mut self,
188 request: tonic::Request<super::GetFileRequest>,
189 ) -> Self::Future {
190 let inner = Arc::clone(&self.0);
191 let fut =
192 async move { <T as FileService>::get_file(&inner, request).await };
193 Box::pin(fut)
194 }
195 }
196 let accept_compression_encodings = self.accept_compression_encodings;
197 let send_compression_encodings = self.send_compression_encodings;
198 let max_decoding_message_size = self.max_decoding_message_size;
199 let max_encoding_message_size = self.max_encoding_message_size;
200 let inner = self.inner.clone();
201 let fut = async move {
202 let method = GetFileSvc(inner);
203 let codec = tonic::codec::ProstCodec::default();
204 let mut grpc = tonic::server::Grpc::new(codec)
205 .apply_compression_config(
206 accept_compression_encodings,
207 send_compression_encodings,
208 )
209 .apply_max_message_size_config(
210 max_decoding_message_size,
211 max_encoding_message_size,
212 );
213 let res = grpc.unary(method, req).await;
214 Ok(res)
215 };
216 Box::pin(fut)
217 }
218 "/google.ai.generativelanguage.v1beta.FileService/DeleteFile" => {
219 #[allow(non_camel_case_types)]
220 struct DeleteFileSvc<T: FileService>(pub Arc<T>);
221 impl<T: FileService> tonic::server::UnaryService<super::DeleteFileRequest> for DeleteFileSvc<T> {
222 type Response = ();
223 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
224 fn call(
225 &mut self,
226 request: tonic::Request<super::DeleteFileRequest>,
227 ) -> Self::Future {
228 let inner = Arc::clone(&self.0);
229 let fut =
230 async move { <T as FileService>::delete_file(&inner, request).await };
231 Box::pin(fut)
232 }
233 }
234 let accept_compression_encodings = self.accept_compression_encodings;
235 let send_compression_encodings = self.send_compression_encodings;
236 let max_decoding_message_size = self.max_decoding_message_size;
237 let max_encoding_message_size = self.max_encoding_message_size;
238 let inner = self.inner.clone();
239 let fut = async move {
240 let method = DeleteFileSvc(inner);
241 let codec = tonic::codec::ProstCodec::default();
242 let mut grpc = tonic::server::Grpc::new(codec)
243 .apply_compression_config(
244 accept_compression_encodings,
245 send_compression_encodings,
246 )
247 .apply_max_message_size_config(
248 max_decoding_message_size,
249 max_encoding_message_size,
250 );
251 let res = grpc.unary(method, req).await;
252 Ok(res)
253 };
254 Box::pin(fut)
255 }
256 _ => Box::pin(async move {
257 let mut response = http::Response::new(tonic::body::Body::default());
258 let headers = response.headers_mut();
259 headers.insert(
260 tonic::Status::GRPC_STATUS,
261 (tonic::Code::Unimplemented as i32).into(),
262 );
263 headers.insert(
264 http::header::CONTENT_TYPE,
265 tonic::metadata::GRPC_CONTENT_TYPE,
266 );
267 Ok(response)
268 }),
269 }
270 }
271}
272impl<T> Clone for FileServiceServer<T> {
273 fn clone(&self) -> Self {
274 let inner = self.inner.clone();
275 Self {
276 inner,
277 accept_compression_encodings: self.accept_compression_encodings,
278 send_compression_encodings: self.send_compression_encodings,
279 max_decoding_message_size: self.max_decoding_message_size,
280 max_encoding_message_size: self.max_encoding_message_size,
281 }
282 }
283}
284pub const SERVICE_NAME: &str = "google.ai.generativelanguage.v1beta.FileService";
286impl<T> tonic::server::NamedService for FileServiceServer<T> {
287 const NAME: &'static str = SERVICE_NAME;
288}