Skip to main content

snip_it/
proto.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct GetSnippetsRequest {
4    #[prost(string, tag = "1")]
5    pub api_key: ::prost::alloc::string::String,
6    #[prost(int64, tag = "2")]
7    pub since: i64,
8    #[prost(string, tag = "3")]
9    pub library_id: ::prost::alloc::string::String,
10    #[prost(int32, tag = "4")]
11    pub limit: i32,
12    #[prost(int32, tag = "5")]
13    pub offset: i32,
14}
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct PushSnippetsRequest {
17    #[prost(string, tag = "1")]
18    pub api_key: ::prost::alloc::string::String,
19    #[prost(string, tag = "3")]
20    pub library_id: ::prost::alloc::string::String,
21    #[prost(message, repeated, tag = "2")]
22    pub snippets: ::prost::alloc::vec::Vec<Snippet>,
23}
24#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
25pub struct PushSnippetsResponse {
26    #[prost(bool, tag = "1")]
27    pub success: bool,
28    #[prost(string, tag = "2")]
29    pub message: ::prost::alloc::string::String,
30    #[prost(int32, tag = "3")]
31    pub accepted_count: i32,
32    #[prost(int32, tag = "4")]
33    pub rejected_count: i32,
34}
35#[derive(Clone, PartialEq, ::prost::Message)]
36pub struct SyncRequest {
37    #[prost(string, tag = "1")]
38    pub api_key: ::prost::alloc::string::String,
39    #[prost(message, repeated, tag = "2")]
40    pub local_snippets: ::prost::alloc::vec::Vec<Snippet>,
41    #[prost(int64, tag = "3")]
42    pub last_sync_timestamp: i64,
43    #[prost(string, tag = "4")]
44    pub library_id: ::prost::alloc::string::String,
45    #[prost(int32, tag = "5")]
46    pub limit: i32,
47    #[prost(int32, tag = "6")]
48    pub offset: i32,
49}
50#[derive(Clone, PartialEq, ::prost::Message)]
51pub struct SyncResponse {
52    #[prost(bool, tag = "1")]
53    pub success: bool,
54    #[prost(string, tag = "2")]
55    pub message: ::prost::alloc::string::String,
56    #[prost(message, repeated, tag = "3")]
57    pub snippets: ::prost::alloc::vec::Vec<Snippet>,
58    #[prost(int64, tag = "4")]
59    pub server_timestamp: i64,
60    #[prost(int32, tag = "5")]
61    pub skipped_count: i32,
62    #[prost(string, repeated, tag = "6")]
63    pub skipped_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
64    #[prost(bool, tag = "7")]
65    pub has_more: bool,
66    #[prost(int32, tag = "8")]
67    pub total_count: i32,
68}
69#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
70pub struct Snippet {
71    #[prost(string, tag = "1")]
72    pub id: ::prost::alloc::string::String,
73    #[prost(string, tag = "2")]
74    pub description: ::prost::alloc::string::String,
75    #[prost(string, tag = "3")]
76    pub command: ::prost::alloc::string::String,
77    #[prost(string, repeated, tag = "4")]
78    pub tags: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
79    #[prost(int64, tag = "5")]
80    pub created_at: i64,
81    #[prost(int64, tag = "6")]
82    pub updated_at: i64,
83    #[prost(string, tag = "7")]
84    pub device_id: ::prost::alloc::string::String,
85    #[prost(bool, tag = "8")]
86    pub deleted: bool,
87    #[prost(bool, tag = "9")]
88    pub encrypted: bool,
89}
90#[derive(Clone, PartialEq, ::prost::Message)]
91pub struct SnippetList {
92    #[prost(message, repeated, tag = "1")]
93    pub snippets: ::prost::alloc::vec::Vec<Snippet>,
94    #[prost(int32, tag = "2")]
95    pub total_count: i32,
96    #[prost(bool, tag = "3")]
97    pub has_more: bool,
98}
99#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
100pub struct HealthRequest {}
101#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
102pub struct HealthResponse {
103    #[prost(bool, tag = "1")]
104    pub healthy: bool,
105    #[prost(string, tag = "2")]
106    pub version: ::prost::alloc::string::String,
107}
108#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
109pub struct RegisterRequest {
110    #[prost(string, tag = "1")]
111    pub device_id: ::prost::alloc::string::String,
112}
113#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
114pub struct RegisterResponse {
115    #[prost(bool, tag = "1")]
116    pub success: bool,
117    #[prost(string, tag = "2")]
118    pub api_key: ::prost::alloc::string::String,
119    #[prost(string, tag = "3")]
120    pub message: ::prost::alloc::string::String,
121    #[prost(string, tag = "4")]
122    pub device_id: ::prost::alloc::string::String,
123}
124#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
125pub struct CreateLibraryRequest {
126    #[prost(string, tag = "1")]
127    pub api_key: ::prost::alloc::string::String,
128    #[prost(string, tag = "2")]
129    pub name: ::prost::alloc::string::String,
130}
131#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
132pub struct CreateLibraryResponse {
133    #[prost(bool, tag = "1")]
134    pub success: bool,
135    #[prost(string, tag = "2")]
136    pub library_id: ::prost::alloc::string::String,
137    #[prost(string, tag = "3")]
138    pub message: ::prost::alloc::string::String,
139}
140#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
141pub struct ListLibrariesRequest {
142    #[prost(string, tag = "1")]
143    pub api_key: ::prost::alloc::string::String,
144    #[prost(int32, tag = "2")]
145    pub limit: i32,
146    #[prost(int32, tag = "3")]
147    pub offset: i32,
148}
149#[derive(Clone, PartialEq, ::prost::Message)]
150pub struct ListLibrariesResponse {
151    #[prost(message, repeated, tag = "1")]
152    pub libraries: ::prost::alloc::vec::Vec<Library>,
153    #[prost(int32, tag = "2")]
154    pub total_count: i32,
155    #[prost(bool, tag = "3")]
156    pub has_more: bool,
157}
158#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
159pub struct DeleteLibraryRequest {
160    #[prost(string, tag = "1")]
161    pub api_key: ::prost::alloc::string::String,
162    #[prost(string, tag = "2")]
163    pub library_id: ::prost::alloc::string::String,
164}
165#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
166pub struct DeleteLibraryResponse {
167    #[prost(bool, tag = "1")]
168    pub success: bool,
169    #[prost(string, tag = "2")]
170    pub message: ::prost::alloc::string::String,
171}
172#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
173pub struct Library {
174    #[prost(string, tag = "1")]
175    pub id: ::prost::alloc::string::String,
176    #[prost(string, tag = "2")]
177    pub name: ::prost::alloc::string::String,
178    #[prost(int64, tag = "3")]
179    pub created_at: i64,
180    #[prost(int64, tag = "4")]
181    pub snippet_count: i64,
182}
183#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
184pub struct ListPremadeLibrariesRequest {
185    #[prost(string, tag = "1")]
186    pub api_key: ::prost::alloc::string::String,
187}
188#[derive(Clone, PartialEq, ::prost::Message)]
189pub struct ListPremadeLibrariesResponse {
190    #[prost(message, repeated, tag = "1")]
191    pub libraries: ::prost::alloc::vec::Vec<PremadeLibrary>,
192    #[prost(bool, tag = "2")]
193    pub has_more: bool,
194    #[prost(int32, tag = "3")]
195    pub total_count: i32,
196}
197#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
198pub struct PremadeLibrary {
199    #[prost(string, tag = "1")]
200    pub name: ::prost::alloc::string::String,
201    #[prost(string, tag = "2")]
202    pub filename: ::prost::alloc::string::String,
203    #[prost(string, tag = "3")]
204    pub description: ::prost::alloc::string::String,
205    #[prost(int32, tag = "4")]
206    pub snippet_count: i32,
207    #[prost(string, repeated, tag = "5")]
208    pub tags: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
209}
210#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
211pub struct GetPremadeLibraryRequest {
212    #[prost(string, tag = "1")]
213    pub api_key: ::prost::alloc::string::String,
214    #[prost(string, tag = "2")]
215    pub filename: ::prost::alloc::string::String,
216}
217#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
218pub struct GetPremadeLibraryResponse {
219    #[prost(bool, tag = "1")]
220    pub success: bool,
221    #[prost(string, tag = "2")]
222    pub name: ::prost::alloc::string::String,
223    #[prost(string, tag = "3")]
224    pub content: ::prost::alloc::string::String,
225    #[prost(string, tag = "4")]
226    pub message: ::prost::alloc::string::String,
227}
228#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
229pub struct SearchPremadeLibrariesRequest {
230    #[prost(string, tag = "1")]
231    pub api_key: ::prost::alloc::string::String,
232    #[prost(string, tag = "2")]
233    pub query: ::prost::alloc::string::String,
234}
235#[derive(Clone, PartialEq, ::prost::Message)]
236pub struct SearchPremadeLibrariesResponse {
237    #[prost(message, repeated, tag = "1")]
238    pub libraries: ::prost::alloc::vec::Vec<PremadeLibrary>,
239    #[prost(int32, tag = "2")]
240    pub total_count: i32,
241}
242/// Generated client implementations.
243pub mod snippet_sync_client {
244    #![allow(
245        unused_variables,
246        dead_code,
247        missing_docs,
248        clippy::wildcard_imports,
249        clippy::let_unit_value
250    )]
251    use tonic::codegen::http::Uri;
252    use tonic::codegen::*;
253    #[derive(Debug, Clone)]
254    pub struct SnippetSyncClient<T> {
255        inner: tonic::client::Grpc<T>,
256    }
257    impl SnippetSyncClient<tonic::transport::Channel> {
258        /// Attempt to create a new client by connecting to a given endpoint.
259        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
260        where
261            D: TryInto<tonic::transport::Endpoint>,
262            D::Error: Into<StdError>,
263        {
264            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
265            Ok(Self::new(conn))
266        }
267    }
268    impl<T> SnippetSyncClient<T>
269    where
270        T: tonic::client::GrpcService<tonic::body::Body>,
271        T::Error: Into<StdError>,
272        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
273        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
274    {
275        pub fn new(inner: T) -> Self {
276            let inner = tonic::client::Grpc::new(inner);
277            Self { inner }
278        }
279        pub fn with_origin(inner: T, origin: Uri) -> Self {
280            let inner = tonic::client::Grpc::with_origin(inner, origin);
281            Self { inner }
282        }
283        pub fn with_interceptor<F>(
284            inner: T,
285            interceptor: F,
286        ) -> SnippetSyncClient<InterceptedService<T, F>>
287        where
288            F: tonic::service::Interceptor,
289            T::ResponseBody: Default,
290            T: tonic::codegen::Service<
291                    http::Request<tonic::body::Body>,
292                    Response = http::Response<
293                        <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
294                    >,
295                >,
296            <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
297                Into<StdError> + std::marker::Send + std::marker::Sync,
298        {
299            SnippetSyncClient::new(InterceptedService::new(inner, interceptor))
300        }
301        /// Compress requests with the given encoding.
302        ///
303        /// This requires the server to support it otherwise it might respond with an
304        /// error.
305        #[must_use]
306        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
307            self.inner = self.inner.send_compressed(encoding);
308            self
309        }
310        /// Enable decompressing responses.
311        #[must_use]
312        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
313            self.inner = self.inner.accept_compressed(encoding);
314            self
315        }
316        /// Limits the maximum size of a decoded message.
317        ///
318        /// Default: `4MB`
319        #[must_use]
320        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
321            self.inner = self.inner.max_decoding_message_size(limit);
322            self
323        }
324        /// Limits the maximum size of an encoded message.
325        ///
326        /// Default: `usize::MAX`
327        #[must_use]
328        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
329            self.inner = self.inner.max_encoding_message_size(limit);
330            self
331        }
332        /// Get snippets from server (optionally since a timestamp)
333        pub async fn get_snippets(
334            &mut self,
335            request: impl tonic::IntoRequest<super::GetSnippetsRequest>,
336        ) -> std::result::Result<tonic::Response<super::SnippetList>, tonic::Status> {
337            self.inner.ready().await.map_err(|e| {
338                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
339            })?;
340            let codec = tonic_prost::ProstCodec::default();
341            let path = http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/GetSnippets");
342            let mut req = request.into_request();
343            req.extensions_mut()
344                .insert(GrpcMethod::new("snip_proto.SnippetSync", "GetSnippets"));
345            self.inner.unary(req, path, codec).await
346        }
347        /// Push local snippets to server
348        pub async fn push_snippets(
349            &mut self,
350            request: impl tonic::IntoRequest<super::PushSnippetsRequest>,
351        ) -> std::result::Result<tonic::Response<super::PushSnippetsResponse>, tonic::Status>
352        {
353            self.inner.ready().await.map_err(|e| {
354                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
355            })?;
356            let codec = tonic_prost::ProstCodec::default();
357            let path = http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/PushSnippets");
358            let mut req = request.into_request();
359            req.extensions_mut()
360                .insert(GrpcMethod::new("snip_proto.SnippetSync", "PushSnippets"));
361            self.inner.unary(req, path, codec).await
362        }
363        /// Two-way sync - merge local and server snippets
364        pub async fn sync(
365            &mut self,
366            request: impl tonic::IntoRequest<super::SyncRequest>,
367        ) -> std::result::Result<tonic::Response<super::SyncResponse>, tonic::Status> {
368            self.inner.ready().await.map_err(|e| {
369                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
370            })?;
371            let codec = tonic_prost::ProstCodec::default();
372            let path = http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/Sync");
373            let mut req = request.into_request();
374            req.extensions_mut()
375                .insert(GrpcMethod::new("snip_proto.SnippetSync", "Sync"));
376            self.inner.unary(req, path, codec).await
377        }
378        /// Health check
379        pub async fn health(
380            &mut self,
381            request: impl tonic::IntoRequest<super::HealthRequest>,
382        ) -> std::result::Result<tonic::Response<super::HealthResponse>, tonic::Status> {
383            self.inner.ready().await.map_err(|e| {
384                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
385            })?;
386            let codec = tonic_prost::ProstCodec::default();
387            let path = http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/Health");
388            let mut req = request.into_request();
389            req.extensions_mut()
390                .insert(GrpcMethod::new("snip_proto.SnippetSync", "Health"));
391            self.inner.unary(req, path, codec).await
392        }
393        /// Register a new device/user
394        pub async fn register(
395            &mut self,
396            request: impl tonic::IntoRequest<super::RegisterRequest>,
397        ) -> std::result::Result<tonic::Response<super::RegisterResponse>, tonic::Status> {
398            self.inner.ready().await.map_err(|e| {
399                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
400            })?;
401            let codec = tonic_prost::ProstCodec::default();
402            let path = http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/Register");
403            let mut req = request.into_request();
404            req.extensions_mut()
405                .insert(GrpcMethod::new("snip_proto.SnippetSync", "Register"));
406            self.inner.unary(req, path, codec).await
407        }
408        /// Library management
409        pub async fn create_library(
410            &mut self,
411            request: impl tonic::IntoRequest<super::CreateLibraryRequest>,
412        ) -> std::result::Result<tonic::Response<super::CreateLibraryResponse>, tonic::Status>
413        {
414            self.inner.ready().await.map_err(|e| {
415                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
416            })?;
417            let codec = tonic_prost::ProstCodec::default();
418            let path =
419                http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/CreateLibrary");
420            let mut req = request.into_request();
421            req.extensions_mut()
422                .insert(GrpcMethod::new("snip_proto.SnippetSync", "CreateLibrary"));
423            self.inner.unary(req, path, codec).await
424        }
425        pub async fn list_libraries(
426            &mut self,
427            request: impl tonic::IntoRequest<super::ListLibrariesRequest>,
428        ) -> std::result::Result<tonic::Response<super::ListLibrariesResponse>, tonic::Status>
429        {
430            self.inner.ready().await.map_err(|e| {
431                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
432            })?;
433            let codec = tonic_prost::ProstCodec::default();
434            let path =
435                http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/ListLibraries");
436            let mut req = request.into_request();
437            req.extensions_mut()
438                .insert(GrpcMethod::new("snip_proto.SnippetSync", "ListLibraries"));
439            self.inner.unary(req, path, codec).await
440        }
441        pub async fn delete_library(
442            &mut self,
443            request: impl tonic::IntoRequest<super::DeleteLibraryRequest>,
444        ) -> std::result::Result<tonic::Response<super::DeleteLibraryResponse>, tonic::Status>
445        {
446            self.inner.ready().await.map_err(|e| {
447                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
448            })?;
449            let codec = tonic_prost::ProstCodec::default();
450            let path =
451                http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/DeleteLibrary");
452            let mut req = request.into_request();
453            req.extensions_mut()
454                .insert(GrpcMethod::new("snip_proto.SnippetSync", "DeleteLibrary"));
455            self.inner.unary(req, path, codec).await
456        }
457        /// Premade libraries (server->client only)
458        pub async fn list_premade_libraries(
459            &mut self,
460            request: impl tonic::IntoRequest<super::ListPremadeLibrariesRequest>,
461        ) -> std::result::Result<tonic::Response<super::ListPremadeLibrariesResponse>, tonic::Status>
462        {
463            self.inner.ready().await.map_err(|e| {
464                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
465            })?;
466            let codec = tonic_prost::ProstCodec::default();
467            let path = http::uri::PathAndQuery::from_static(
468                "/snip_proto.SnippetSync/ListPremadeLibraries",
469            );
470            let mut req = request.into_request();
471            req.extensions_mut().insert(GrpcMethod::new(
472                "snip_proto.SnippetSync",
473                "ListPremadeLibraries",
474            ));
475            self.inner.unary(req, path, codec).await
476        }
477        pub async fn get_premade_library(
478            &mut self,
479            request: impl tonic::IntoRequest<super::GetPremadeLibraryRequest>,
480        ) -> std::result::Result<tonic::Response<super::GetPremadeLibraryResponse>, tonic::Status>
481        {
482            self.inner.ready().await.map_err(|e| {
483                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
484            })?;
485            let codec = tonic_prost::ProstCodec::default();
486            let path =
487                http::uri::PathAndQuery::from_static("/snip_proto.SnippetSync/GetPremadeLibrary");
488            let mut req = request.into_request();
489            req.extensions_mut().insert(GrpcMethod::new(
490                "snip_proto.SnippetSync",
491                "GetPremadeLibrary",
492            ));
493            self.inner.unary(req, path, codec).await
494        }
495        pub async fn search_premade_libraries(
496            &mut self,
497            request: impl tonic::IntoRequest<super::SearchPremadeLibrariesRequest>,
498        ) -> std::result::Result<
499            tonic::Response<super::SearchPremadeLibrariesResponse>,
500            tonic::Status,
501        > {
502            self.inner.ready().await.map_err(|e| {
503                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
504            })?;
505            let codec = tonic_prost::ProstCodec::default();
506            let path = http::uri::PathAndQuery::from_static(
507                "/snip_proto.SnippetSync/SearchPremadeLibraries",
508            );
509            let mut req = request.into_request();
510            req.extensions_mut().insert(GrpcMethod::new(
511                "snip_proto.SnippetSync",
512                "SearchPremadeLibraries",
513            ));
514            self.inner.unary(req, path, codec).await
515        }
516    }
517}
518/// Generated server implementations.
519pub mod snippet_sync_server {
520    #![allow(
521        unused_variables,
522        dead_code,
523        missing_docs,
524        clippy::wildcard_imports,
525        clippy::let_unit_value
526    )]
527    use tonic::codegen::*;
528    /// Generated trait containing gRPC methods that should be implemented for use with SnippetSyncServer.
529    #[async_trait]
530    pub trait SnippetSync: std::marker::Send + std::marker::Sync + 'static {
531        /// Get snippets from server (optionally since a timestamp)
532        async fn get_snippets(
533            &self,
534            request: tonic::Request<super::GetSnippetsRequest>,
535        ) -> std::result::Result<tonic::Response<super::SnippetList>, tonic::Status>;
536        /// Push local snippets to server
537        async fn push_snippets(
538            &self,
539            request: tonic::Request<super::PushSnippetsRequest>,
540        ) -> std::result::Result<tonic::Response<super::PushSnippetsResponse>, tonic::Status>;
541        /// Two-way sync - merge local and server snippets
542        async fn sync(
543            &self,
544            request: tonic::Request<super::SyncRequest>,
545        ) -> std::result::Result<tonic::Response<super::SyncResponse>, tonic::Status>;
546        /// Health check
547        async fn health(
548            &self,
549            request: tonic::Request<super::HealthRequest>,
550        ) -> std::result::Result<tonic::Response<super::HealthResponse>, tonic::Status>;
551        /// Register a new device/user
552        async fn register(
553            &self,
554            request: tonic::Request<super::RegisterRequest>,
555        ) -> std::result::Result<tonic::Response<super::RegisterResponse>, tonic::Status>;
556        /// Library management
557        async fn create_library(
558            &self,
559            request: tonic::Request<super::CreateLibraryRequest>,
560        ) -> std::result::Result<tonic::Response<super::CreateLibraryResponse>, tonic::Status>;
561        async fn list_libraries(
562            &self,
563            request: tonic::Request<super::ListLibrariesRequest>,
564        ) -> std::result::Result<tonic::Response<super::ListLibrariesResponse>, tonic::Status>;
565        async fn delete_library(
566            &self,
567            request: tonic::Request<super::DeleteLibraryRequest>,
568        ) -> std::result::Result<tonic::Response<super::DeleteLibraryResponse>, tonic::Status>;
569        /// Premade libraries (server->client only)
570        async fn list_premade_libraries(
571            &self,
572            request: tonic::Request<super::ListPremadeLibrariesRequest>,
573        ) -> std::result::Result<tonic::Response<super::ListPremadeLibrariesResponse>, tonic::Status>;
574        async fn get_premade_library(
575            &self,
576            request: tonic::Request<super::GetPremadeLibraryRequest>,
577        ) -> std::result::Result<tonic::Response<super::GetPremadeLibraryResponse>, tonic::Status>;
578        async fn search_premade_libraries(
579            &self,
580            request: tonic::Request<super::SearchPremadeLibrariesRequest>,
581        ) -> std::result::Result<
582            tonic::Response<super::SearchPremadeLibrariesResponse>,
583            tonic::Status,
584        >;
585    }
586    #[derive(Debug)]
587    pub struct SnippetSyncServer<T> {
588        inner: Arc<T>,
589        accept_compression_encodings: EnabledCompressionEncodings,
590        send_compression_encodings: EnabledCompressionEncodings,
591        max_decoding_message_size: Option<usize>,
592        max_encoding_message_size: Option<usize>,
593    }
594    impl<T> SnippetSyncServer<T> {
595        pub fn new(inner: T) -> Self {
596            Self::from_arc(Arc::new(inner))
597        }
598        pub fn from_arc(inner: Arc<T>) -> Self {
599            Self {
600                inner,
601                accept_compression_encodings: Default::default(),
602                send_compression_encodings: Default::default(),
603                max_decoding_message_size: None,
604                max_encoding_message_size: None,
605            }
606        }
607        pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
608        where
609            F: tonic::service::Interceptor,
610        {
611            InterceptedService::new(Self::new(inner), interceptor)
612        }
613        /// Enable decompressing requests with the given encoding.
614        #[must_use]
615        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
616            self.accept_compression_encodings.enable(encoding);
617            self
618        }
619        /// Compress responses with the given encoding, if the client supports it.
620        #[must_use]
621        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
622            self.send_compression_encodings.enable(encoding);
623            self
624        }
625        /// Limits the maximum size of a decoded message.
626        ///
627        /// Default: `4MB`
628        #[must_use]
629        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
630            self.max_decoding_message_size = Some(limit);
631            self
632        }
633        /// Limits the maximum size of an encoded message.
634        ///
635        /// Default: `usize::MAX`
636        #[must_use]
637        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
638            self.max_encoding_message_size = Some(limit);
639            self
640        }
641    }
642    impl<T, B> tonic::codegen::Service<http::Request<B>> for SnippetSyncServer<T>
643    where
644        T: SnippetSync,
645        B: Body + std::marker::Send + 'static,
646        B::Error: Into<StdError> + std::marker::Send + 'static,
647    {
648        type Response = http::Response<tonic::body::Body>;
649        type Error = std::convert::Infallible;
650        type Future = BoxFuture<Self::Response, Self::Error>;
651        fn poll_ready(
652            &mut self,
653            _cx: &mut Context<'_>,
654        ) -> Poll<std::result::Result<(), Self::Error>> {
655            Poll::Ready(Ok(()))
656        }
657        fn call(&mut self, req: http::Request<B>) -> Self::Future {
658            match req.uri().path() {
659                "/snip_proto.SnippetSync/GetSnippets" => {
660                    #[allow(non_camel_case_types)]
661                    struct GetSnippetsSvc<T: SnippetSync>(pub Arc<T>);
662                    impl<T: SnippetSync> tonic::server::UnaryService<super::GetSnippetsRequest> for GetSnippetsSvc<T> {
663                        type Response = super::SnippetList;
664                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
665                        fn call(
666                            &mut self,
667                            request: tonic::Request<super::GetSnippetsRequest>,
668                        ) -> Self::Future {
669                            let inner = Arc::clone(&self.0);
670                            let fut = async move {
671                                <T as SnippetSync>::get_snippets(&inner, request).await
672                            };
673                            Box::pin(fut)
674                        }
675                    }
676                    let accept_compression_encodings = self.accept_compression_encodings;
677                    let send_compression_encodings = self.send_compression_encodings;
678                    let max_decoding_message_size = self.max_decoding_message_size;
679                    let max_encoding_message_size = self.max_encoding_message_size;
680                    let inner = self.inner.clone();
681                    let fut = async move {
682                        let method = GetSnippetsSvc(inner);
683                        let codec = tonic_prost::ProstCodec::default();
684                        let mut grpc = tonic::server::Grpc::new(codec)
685                            .apply_compression_config(
686                                accept_compression_encodings,
687                                send_compression_encodings,
688                            )
689                            .apply_max_message_size_config(
690                                max_decoding_message_size,
691                                max_encoding_message_size,
692                            );
693                        let res = grpc.unary(method, req).await;
694                        Ok(res)
695                    };
696                    Box::pin(fut)
697                }
698                "/snip_proto.SnippetSync/PushSnippets" => {
699                    #[allow(non_camel_case_types)]
700                    struct PushSnippetsSvc<T: SnippetSync>(pub Arc<T>);
701                    impl<T: SnippetSync> tonic::server::UnaryService<super::PushSnippetsRequest>
702                        for PushSnippetsSvc<T>
703                    {
704                        type Response = super::PushSnippetsResponse;
705                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
706                        fn call(
707                            &mut self,
708                            request: tonic::Request<super::PushSnippetsRequest>,
709                        ) -> Self::Future {
710                            let inner = Arc::clone(&self.0);
711                            let fut = async move {
712                                <T as SnippetSync>::push_snippets(&inner, request).await
713                            };
714                            Box::pin(fut)
715                        }
716                    }
717                    let accept_compression_encodings = self.accept_compression_encodings;
718                    let send_compression_encodings = self.send_compression_encodings;
719                    let max_decoding_message_size = self.max_decoding_message_size;
720                    let max_encoding_message_size = self.max_encoding_message_size;
721                    let inner = self.inner.clone();
722                    let fut = async move {
723                        let method = PushSnippetsSvc(inner);
724                        let codec = tonic_prost::ProstCodec::default();
725                        let mut grpc = tonic::server::Grpc::new(codec)
726                            .apply_compression_config(
727                                accept_compression_encodings,
728                                send_compression_encodings,
729                            )
730                            .apply_max_message_size_config(
731                                max_decoding_message_size,
732                                max_encoding_message_size,
733                            );
734                        let res = grpc.unary(method, req).await;
735                        Ok(res)
736                    };
737                    Box::pin(fut)
738                }
739                "/snip_proto.SnippetSync/Sync" => {
740                    #[allow(non_camel_case_types)]
741                    struct SyncSvc<T: SnippetSync>(pub Arc<T>);
742                    impl<T: SnippetSync> tonic::server::UnaryService<super::SyncRequest> for SyncSvc<T> {
743                        type Response = super::SyncResponse;
744                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
745                        fn call(
746                            &mut self,
747                            request: tonic::Request<super::SyncRequest>,
748                        ) -> Self::Future {
749                            let inner = Arc::clone(&self.0);
750                            let fut =
751                                async move { <T as SnippetSync>::sync(&inner, request).await };
752                            Box::pin(fut)
753                        }
754                    }
755                    let accept_compression_encodings = self.accept_compression_encodings;
756                    let send_compression_encodings = self.send_compression_encodings;
757                    let max_decoding_message_size = self.max_decoding_message_size;
758                    let max_encoding_message_size = self.max_encoding_message_size;
759                    let inner = self.inner.clone();
760                    let fut = async move {
761                        let method = SyncSvc(inner);
762                        let codec = tonic_prost::ProstCodec::default();
763                        let mut grpc = tonic::server::Grpc::new(codec)
764                            .apply_compression_config(
765                                accept_compression_encodings,
766                                send_compression_encodings,
767                            )
768                            .apply_max_message_size_config(
769                                max_decoding_message_size,
770                                max_encoding_message_size,
771                            );
772                        let res = grpc.unary(method, req).await;
773                        Ok(res)
774                    };
775                    Box::pin(fut)
776                }
777                "/snip_proto.SnippetSync/Health" => {
778                    #[allow(non_camel_case_types)]
779                    struct HealthSvc<T: SnippetSync>(pub Arc<T>);
780                    impl<T: SnippetSync> tonic::server::UnaryService<super::HealthRequest> for HealthSvc<T> {
781                        type Response = super::HealthResponse;
782                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
783                        fn call(
784                            &mut self,
785                            request: tonic::Request<super::HealthRequest>,
786                        ) -> Self::Future {
787                            let inner = Arc::clone(&self.0);
788                            let fut =
789                                async move { <T as SnippetSync>::health(&inner, request).await };
790                            Box::pin(fut)
791                        }
792                    }
793                    let accept_compression_encodings = self.accept_compression_encodings;
794                    let send_compression_encodings = self.send_compression_encodings;
795                    let max_decoding_message_size = self.max_decoding_message_size;
796                    let max_encoding_message_size = self.max_encoding_message_size;
797                    let inner = self.inner.clone();
798                    let fut = async move {
799                        let method = HealthSvc(inner);
800                        let codec = tonic_prost::ProstCodec::default();
801                        let mut grpc = tonic::server::Grpc::new(codec)
802                            .apply_compression_config(
803                                accept_compression_encodings,
804                                send_compression_encodings,
805                            )
806                            .apply_max_message_size_config(
807                                max_decoding_message_size,
808                                max_encoding_message_size,
809                            );
810                        let res = grpc.unary(method, req).await;
811                        Ok(res)
812                    };
813                    Box::pin(fut)
814                }
815                "/snip_proto.SnippetSync/Register" => {
816                    #[allow(non_camel_case_types)]
817                    struct RegisterSvc<T: SnippetSync>(pub Arc<T>);
818                    impl<T: SnippetSync> tonic::server::UnaryService<super::RegisterRequest> for RegisterSvc<T> {
819                        type Response = super::RegisterResponse;
820                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
821                        fn call(
822                            &mut self,
823                            request: tonic::Request<super::RegisterRequest>,
824                        ) -> Self::Future {
825                            let inner = Arc::clone(&self.0);
826                            let fut =
827                                async move { <T as SnippetSync>::register(&inner, request).await };
828                            Box::pin(fut)
829                        }
830                    }
831                    let accept_compression_encodings = self.accept_compression_encodings;
832                    let send_compression_encodings = self.send_compression_encodings;
833                    let max_decoding_message_size = self.max_decoding_message_size;
834                    let max_encoding_message_size = self.max_encoding_message_size;
835                    let inner = self.inner.clone();
836                    let fut = async move {
837                        let method = RegisterSvc(inner);
838                        let codec = tonic_prost::ProstCodec::default();
839                        let mut grpc = tonic::server::Grpc::new(codec)
840                            .apply_compression_config(
841                                accept_compression_encodings,
842                                send_compression_encodings,
843                            )
844                            .apply_max_message_size_config(
845                                max_decoding_message_size,
846                                max_encoding_message_size,
847                            );
848                        let res = grpc.unary(method, req).await;
849                        Ok(res)
850                    };
851                    Box::pin(fut)
852                }
853                "/snip_proto.SnippetSync/CreateLibrary" => {
854                    #[allow(non_camel_case_types)]
855                    struct CreateLibrarySvc<T: SnippetSync>(pub Arc<T>);
856                    impl<T: SnippetSync> tonic::server::UnaryService<super::CreateLibraryRequest>
857                        for CreateLibrarySvc<T>
858                    {
859                        type Response = super::CreateLibraryResponse;
860                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
861                        fn call(
862                            &mut self,
863                            request: tonic::Request<super::CreateLibraryRequest>,
864                        ) -> Self::Future {
865                            let inner = Arc::clone(&self.0);
866                            let fut = async move {
867                                <T as SnippetSync>::create_library(&inner, request).await
868                            };
869                            Box::pin(fut)
870                        }
871                    }
872                    let accept_compression_encodings = self.accept_compression_encodings;
873                    let send_compression_encodings = self.send_compression_encodings;
874                    let max_decoding_message_size = self.max_decoding_message_size;
875                    let max_encoding_message_size = self.max_encoding_message_size;
876                    let inner = self.inner.clone();
877                    let fut = async move {
878                        let method = CreateLibrarySvc(inner);
879                        let codec = tonic_prost::ProstCodec::default();
880                        let mut grpc = tonic::server::Grpc::new(codec)
881                            .apply_compression_config(
882                                accept_compression_encodings,
883                                send_compression_encodings,
884                            )
885                            .apply_max_message_size_config(
886                                max_decoding_message_size,
887                                max_encoding_message_size,
888                            );
889                        let res = grpc.unary(method, req).await;
890                        Ok(res)
891                    };
892                    Box::pin(fut)
893                }
894                "/snip_proto.SnippetSync/ListLibraries" => {
895                    #[allow(non_camel_case_types)]
896                    struct ListLibrariesSvc<T: SnippetSync>(pub Arc<T>);
897                    impl<T: SnippetSync> tonic::server::UnaryService<super::ListLibrariesRequest>
898                        for ListLibrariesSvc<T>
899                    {
900                        type Response = super::ListLibrariesResponse;
901                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
902                        fn call(
903                            &mut self,
904                            request: tonic::Request<super::ListLibrariesRequest>,
905                        ) -> Self::Future {
906                            let inner = Arc::clone(&self.0);
907                            let fut = async move {
908                                <T as SnippetSync>::list_libraries(&inner, request).await
909                            };
910                            Box::pin(fut)
911                        }
912                    }
913                    let accept_compression_encodings = self.accept_compression_encodings;
914                    let send_compression_encodings = self.send_compression_encodings;
915                    let max_decoding_message_size = self.max_decoding_message_size;
916                    let max_encoding_message_size = self.max_encoding_message_size;
917                    let inner = self.inner.clone();
918                    let fut = async move {
919                        let method = ListLibrariesSvc(inner);
920                        let codec = tonic_prost::ProstCodec::default();
921                        let mut grpc = tonic::server::Grpc::new(codec)
922                            .apply_compression_config(
923                                accept_compression_encodings,
924                                send_compression_encodings,
925                            )
926                            .apply_max_message_size_config(
927                                max_decoding_message_size,
928                                max_encoding_message_size,
929                            );
930                        let res = grpc.unary(method, req).await;
931                        Ok(res)
932                    };
933                    Box::pin(fut)
934                }
935                "/snip_proto.SnippetSync/DeleteLibrary" => {
936                    #[allow(non_camel_case_types)]
937                    struct DeleteLibrarySvc<T: SnippetSync>(pub Arc<T>);
938                    impl<T: SnippetSync> tonic::server::UnaryService<super::DeleteLibraryRequest>
939                        for DeleteLibrarySvc<T>
940                    {
941                        type Response = super::DeleteLibraryResponse;
942                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
943                        fn call(
944                            &mut self,
945                            request: tonic::Request<super::DeleteLibraryRequest>,
946                        ) -> Self::Future {
947                            let inner = Arc::clone(&self.0);
948                            let fut = async move {
949                                <T as SnippetSync>::delete_library(&inner, request).await
950                            };
951                            Box::pin(fut)
952                        }
953                    }
954                    let accept_compression_encodings = self.accept_compression_encodings;
955                    let send_compression_encodings = self.send_compression_encodings;
956                    let max_decoding_message_size = self.max_decoding_message_size;
957                    let max_encoding_message_size = self.max_encoding_message_size;
958                    let inner = self.inner.clone();
959                    let fut = async move {
960                        let method = DeleteLibrarySvc(inner);
961                        let codec = tonic_prost::ProstCodec::default();
962                        let mut grpc = tonic::server::Grpc::new(codec)
963                            .apply_compression_config(
964                                accept_compression_encodings,
965                                send_compression_encodings,
966                            )
967                            .apply_max_message_size_config(
968                                max_decoding_message_size,
969                                max_encoding_message_size,
970                            );
971                        let res = grpc.unary(method, req).await;
972                        Ok(res)
973                    };
974                    Box::pin(fut)
975                }
976                "/snip_proto.SnippetSync/ListPremadeLibraries" => {
977                    #[allow(non_camel_case_types)]
978                    struct ListPremadeLibrariesSvc<T: SnippetSync>(pub Arc<T>);
979                    impl<T: SnippetSync>
980                        tonic::server::UnaryService<super::ListPremadeLibrariesRequest>
981                        for ListPremadeLibrariesSvc<T>
982                    {
983                        type Response = super::ListPremadeLibrariesResponse;
984                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
985                        fn call(
986                            &mut self,
987                            request: tonic::Request<super::ListPremadeLibrariesRequest>,
988                        ) -> Self::Future {
989                            let inner = Arc::clone(&self.0);
990                            let fut = async move {
991                                <T as SnippetSync>::list_premade_libraries(&inner, request).await
992                            };
993                            Box::pin(fut)
994                        }
995                    }
996                    let accept_compression_encodings = self.accept_compression_encodings;
997                    let send_compression_encodings = self.send_compression_encodings;
998                    let max_decoding_message_size = self.max_decoding_message_size;
999                    let max_encoding_message_size = self.max_encoding_message_size;
1000                    let inner = self.inner.clone();
1001                    let fut = async move {
1002                        let method = ListPremadeLibrariesSvc(inner);
1003                        let codec = tonic_prost::ProstCodec::default();
1004                        let mut grpc = tonic::server::Grpc::new(codec)
1005                            .apply_compression_config(
1006                                accept_compression_encodings,
1007                                send_compression_encodings,
1008                            )
1009                            .apply_max_message_size_config(
1010                                max_decoding_message_size,
1011                                max_encoding_message_size,
1012                            );
1013                        let res = grpc.unary(method, req).await;
1014                        Ok(res)
1015                    };
1016                    Box::pin(fut)
1017                }
1018                "/snip_proto.SnippetSync/GetPremadeLibrary" => {
1019                    #[allow(non_camel_case_types)]
1020                    struct GetPremadeLibrarySvc<T: SnippetSync>(pub Arc<T>);
1021                    impl<T: SnippetSync>
1022                        tonic::server::UnaryService<super::GetPremadeLibraryRequest>
1023                        for GetPremadeLibrarySvc<T>
1024                    {
1025                        type Response = super::GetPremadeLibraryResponse;
1026                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
1027                        fn call(
1028                            &mut self,
1029                            request: tonic::Request<super::GetPremadeLibraryRequest>,
1030                        ) -> Self::Future {
1031                            let inner = Arc::clone(&self.0);
1032                            let fut = async move {
1033                                <T as SnippetSync>::get_premade_library(&inner, request).await
1034                            };
1035                            Box::pin(fut)
1036                        }
1037                    }
1038                    let accept_compression_encodings = self.accept_compression_encodings;
1039                    let send_compression_encodings = self.send_compression_encodings;
1040                    let max_decoding_message_size = self.max_decoding_message_size;
1041                    let max_encoding_message_size = self.max_encoding_message_size;
1042                    let inner = self.inner.clone();
1043                    let fut = async move {
1044                        let method = GetPremadeLibrarySvc(inner);
1045                        let codec = tonic_prost::ProstCodec::default();
1046                        let mut grpc = tonic::server::Grpc::new(codec)
1047                            .apply_compression_config(
1048                                accept_compression_encodings,
1049                                send_compression_encodings,
1050                            )
1051                            .apply_max_message_size_config(
1052                                max_decoding_message_size,
1053                                max_encoding_message_size,
1054                            );
1055                        let res = grpc.unary(method, req).await;
1056                        Ok(res)
1057                    };
1058                    Box::pin(fut)
1059                }
1060                "/snip_proto.SnippetSync/SearchPremadeLibraries" => {
1061                    #[allow(non_camel_case_types)]
1062                    struct SearchPremadeLibrariesSvc<T: SnippetSync>(pub Arc<T>);
1063                    impl<T: SnippetSync>
1064                        tonic::server::UnaryService<super::SearchPremadeLibrariesRequest>
1065                        for SearchPremadeLibrariesSvc<T>
1066                    {
1067                        type Response = super::SearchPremadeLibrariesResponse;
1068                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
1069                        fn call(
1070                            &mut self,
1071                            request: tonic::Request<super::SearchPremadeLibrariesRequest>,
1072                        ) -> Self::Future {
1073                            let inner = Arc::clone(&self.0);
1074                            let fut = async move {
1075                                <T as SnippetSync>::search_premade_libraries(&inner, request).await
1076                            };
1077                            Box::pin(fut)
1078                        }
1079                    }
1080                    let accept_compression_encodings = self.accept_compression_encodings;
1081                    let send_compression_encodings = self.send_compression_encodings;
1082                    let max_decoding_message_size = self.max_decoding_message_size;
1083                    let max_encoding_message_size = self.max_encoding_message_size;
1084                    let inner = self.inner.clone();
1085                    let fut = async move {
1086                        let method = SearchPremadeLibrariesSvc(inner);
1087                        let codec = tonic_prost::ProstCodec::default();
1088                        let mut grpc = tonic::server::Grpc::new(codec)
1089                            .apply_compression_config(
1090                                accept_compression_encodings,
1091                                send_compression_encodings,
1092                            )
1093                            .apply_max_message_size_config(
1094                                max_decoding_message_size,
1095                                max_encoding_message_size,
1096                            );
1097                        let res = grpc.unary(method, req).await;
1098                        Ok(res)
1099                    };
1100                    Box::pin(fut)
1101                }
1102                _ => Box::pin(async move {
1103                    let mut response = http::Response::new(tonic::body::Body::default());
1104                    let headers = response.headers_mut();
1105                    headers.insert(
1106                        tonic::Status::GRPC_STATUS,
1107                        (tonic::Code::Unimplemented as i32).into(),
1108                    );
1109                    headers.insert(
1110                        http::header::CONTENT_TYPE,
1111                        tonic::metadata::GRPC_CONTENT_TYPE,
1112                    );
1113                    Ok(response)
1114                }),
1115            }
1116        }
1117    }
1118    impl<T> Clone for SnippetSyncServer<T> {
1119        fn clone(&self) -> Self {
1120            let inner = self.inner.clone();
1121            Self {
1122                inner,
1123                accept_compression_encodings: self.accept_compression_encodings,
1124                send_compression_encodings: self.send_compression_encodings,
1125                max_decoding_message_size: self.max_decoding_message_size,
1126                max_encoding_message_size: self.max_encoding_message_size,
1127            }
1128        }
1129    }
1130    /// Generated gRPC service name
1131    pub const SERVICE_NAME: &str = "snip_proto.SnippetSync";
1132    impl<T> tonic::server::NamedService for SnippetSyncServer<T> {
1133        const NAME: &'static str = SERVICE_NAME;
1134    }
1135}