nullnet_libwallguard/proto/
wallguard_service.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ControlChannelRequest {
4    #[prost(string, tag = "1")]
5    pub app_id: ::prost::alloc::string::String,
6    #[prost(string, tag = "2")]
7    pub app_secret: ::prost::alloc::string::String,
8}
9/// Generated client implementations.
10pub mod wall_guard_client {
11    #![allow(
12        unused_variables,
13        dead_code,
14        missing_docs,
15        clippy::wildcard_imports,
16        clippy::let_unit_value,
17    )]
18    use tonic::codegen::*;
19    use tonic::codegen::http::Uri;
20    #[derive(Debug, Clone)]
21    pub struct WallGuardClient<T> {
22        inner: tonic::client::Grpc<T>,
23    }
24    impl WallGuardClient<tonic::transport::Channel> {
25        /// Attempt to create a new client by connecting to a given endpoint.
26        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
27        where
28            D: TryInto<tonic::transport::Endpoint>,
29            D::Error: Into<StdError>,
30        {
31            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
32            Ok(Self::new(conn))
33        }
34    }
35    impl<T> WallGuardClient<T>
36    where
37        T: tonic::client::GrpcService<tonic::body::Body>,
38        T::Error: Into<StdError>,
39        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
40        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
41    {
42        pub fn new(inner: T) -> Self {
43            let inner = tonic::client::Grpc::new(inner);
44            Self { inner }
45        }
46        pub fn with_origin(inner: T, origin: Uri) -> Self {
47            let inner = tonic::client::Grpc::with_origin(inner, origin);
48            Self { inner }
49        }
50        pub fn with_interceptor<F>(
51            inner: T,
52            interceptor: F,
53        ) -> WallGuardClient<InterceptedService<T, F>>
54        where
55            F: tonic::service::Interceptor,
56            T::ResponseBody: Default,
57            T: tonic::codegen::Service<
58                http::Request<tonic::body::Body>,
59                Response = http::Response<
60                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
61                >,
62            >,
63            <T as tonic::codegen::Service<
64                http::Request<tonic::body::Body>,
65            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
66        {
67            WallGuardClient::new(InterceptedService::new(inner, interceptor))
68        }
69        /// Compress requests with the given encoding.
70        ///
71        /// This requires the server to support it otherwise it might respond with an
72        /// error.
73        #[must_use]
74        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
75            self.inner = self.inner.send_compressed(encoding);
76            self
77        }
78        /// Enable decompressing responses.
79        #[must_use]
80        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
81            self.inner = self.inner.accept_compressed(encoding);
82            self
83        }
84        /// Limits the maximum size of a decoded message.
85        ///
86        /// Default: `4MB`
87        #[must_use]
88        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
89            self.inner = self.inner.max_decoding_message_size(limit);
90            self
91        }
92        /// Limits the maximum size of an encoded message.
93        ///
94        /// Default: `usize::MAX`
95        #[must_use]
96        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
97            self.inner = self.inner.max_encoding_message_size(limit);
98            self
99        }
100        pub async fn control_channel(
101            &mut self,
102            request: impl tonic::IntoRequest<super::ControlChannelRequest>,
103        ) -> std::result::Result<
104            tonic::Response<
105                tonic::codec::Streaming<
106                    super::super::wallguard_commands::WallGuardCommand,
107                >,
108            >,
109            tonic::Status,
110        > {
111            self.inner
112                .ready()
113                .await
114                .map_err(|e| {
115                    tonic::Status::unknown(
116                        format!("Service was not ready: {}", e.into()),
117                    )
118                })?;
119            let codec = tonic::codec::ProstCodec::default();
120            let path = http::uri::PathAndQuery::from_static(
121                "/wallguard_service.WallGuard/ControlChannel",
122            );
123            let mut req = request.into_request();
124            req.extensions_mut()
125                .insert(
126                    GrpcMethod::new("wallguard_service.WallGuard", "ControlChannel"),
127                );
128            self.inner.server_streaming(req, path, codec).await
129        }
130    }
131}
132/// Generated server implementations.
133pub mod wall_guard_server {
134    #![allow(
135        unused_variables,
136        dead_code,
137        missing_docs,
138        clippy::wildcard_imports,
139        clippy::let_unit_value,
140    )]
141    use tonic::codegen::*;
142    /// Generated trait containing gRPC methods that should be implemented for use with WallGuardServer.
143    #[async_trait]
144    pub trait WallGuard: std::marker::Send + std::marker::Sync + 'static {
145        /// Server streaming response type for the ControlChannel method.
146        type ControlChannelStream: tonic::codegen::tokio_stream::Stream<
147                Item = std::result::Result<
148                    super::super::wallguard_commands::WallGuardCommand,
149                    tonic::Status,
150                >,
151            >
152            + std::marker::Send
153            + 'static;
154        async fn control_channel(
155            &self,
156            request: tonic::Request<super::ControlChannelRequest>,
157        ) -> std::result::Result<
158            tonic::Response<Self::ControlChannelStream>,
159            tonic::Status,
160        >;
161    }
162    #[derive(Debug)]
163    pub struct WallGuardServer<T> {
164        inner: Arc<T>,
165        accept_compression_encodings: EnabledCompressionEncodings,
166        send_compression_encodings: EnabledCompressionEncodings,
167        max_decoding_message_size: Option<usize>,
168        max_encoding_message_size: Option<usize>,
169    }
170    impl<T> WallGuardServer<T> {
171        pub fn new(inner: T) -> Self {
172            Self::from_arc(Arc::new(inner))
173        }
174        pub fn from_arc(inner: Arc<T>) -> Self {
175            Self {
176                inner,
177                accept_compression_encodings: Default::default(),
178                send_compression_encodings: Default::default(),
179                max_decoding_message_size: None,
180                max_encoding_message_size: None,
181            }
182        }
183        pub fn with_interceptor<F>(
184            inner: T,
185            interceptor: F,
186        ) -> InterceptedService<Self, F>
187        where
188            F: tonic::service::Interceptor,
189        {
190            InterceptedService::new(Self::new(inner), interceptor)
191        }
192        /// Enable decompressing requests with the given encoding.
193        #[must_use]
194        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
195            self.accept_compression_encodings.enable(encoding);
196            self
197        }
198        /// Compress responses with the given encoding, if the client supports it.
199        #[must_use]
200        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
201            self.send_compression_encodings.enable(encoding);
202            self
203        }
204        /// Limits the maximum size of a decoded message.
205        ///
206        /// Default: `4MB`
207        #[must_use]
208        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
209            self.max_decoding_message_size = Some(limit);
210            self
211        }
212        /// Limits the maximum size of an encoded message.
213        ///
214        /// Default: `usize::MAX`
215        #[must_use]
216        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
217            self.max_encoding_message_size = Some(limit);
218            self
219        }
220    }
221    impl<T, B> tonic::codegen::Service<http::Request<B>> for WallGuardServer<T>
222    where
223        T: WallGuard,
224        B: Body + std::marker::Send + 'static,
225        B::Error: Into<StdError> + std::marker::Send + 'static,
226    {
227        type Response = http::Response<tonic::body::Body>;
228        type Error = std::convert::Infallible;
229        type Future = BoxFuture<Self::Response, Self::Error>;
230        fn poll_ready(
231            &mut self,
232            _cx: &mut Context<'_>,
233        ) -> Poll<std::result::Result<(), Self::Error>> {
234            Poll::Ready(Ok(()))
235        }
236        fn call(&mut self, req: http::Request<B>) -> Self::Future {
237            match req.uri().path() {
238                "/wallguard_service.WallGuard/ControlChannel" => {
239                    #[allow(non_camel_case_types)]
240                    struct ControlChannelSvc<T: WallGuard>(pub Arc<T>);
241                    impl<
242                        T: WallGuard,
243                    > tonic::server::ServerStreamingService<super::ControlChannelRequest>
244                    for ControlChannelSvc<T> {
245                        type Response = super::super::wallguard_commands::WallGuardCommand;
246                        type ResponseStream = T::ControlChannelStream;
247                        type Future = BoxFuture<
248                            tonic::Response<Self::ResponseStream>,
249                            tonic::Status,
250                        >;
251                        fn call(
252                            &mut self,
253                            request: tonic::Request<super::ControlChannelRequest>,
254                        ) -> Self::Future {
255                            let inner = Arc::clone(&self.0);
256                            let fut = async move {
257                                <T as WallGuard>::control_channel(&inner, request).await
258                            };
259                            Box::pin(fut)
260                        }
261                    }
262                    let accept_compression_encodings = self.accept_compression_encodings;
263                    let send_compression_encodings = self.send_compression_encodings;
264                    let max_decoding_message_size = self.max_decoding_message_size;
265                    let max_encoding_message_size = self.max_encoding_message_size;
266                    let inner = self.inner.clone();
267                    let fut = async move {
268                        let method = ControlChannelSvc(inner);
269                        let codec = tonic::codec::ProstCodec::default();
270                        let mut grpc = tonic::server::Grpc::new(codec)
271                            .apply_compression_config(
272                                accept_compression_encodings,
273                                send_compression_encodings,
274                            )
275                            .apply_max_message_size_config(
276                                max_decoding_message_size,
277                                max_encoding_message_size,
278                            );
279                        let res = grpc.server_streaming(method, req).await;
280                        Ok(res)
281                    };
282                    Box::pin(fut)
283                }
284                _ => {
285                    Box::pin(async move {
286                        let mut response = http::Response::new(
287                            tonic::body::Body::default(),
288                        );
289                        let headers = response.headers_mut();
290                        headers
291                            .insert(
292                                tonic::Status::GRPC_STATUS,
293                                (tonic::Code::Unimplemented as i32).into(),
294                            );
295                        headers
296                            .insert(
297                                http::header::CONTENT_TYPE,
298                                tonic::metadata::GRPC_CONTENT_TYPE,
299                            );
300                        Ok(response)
301                    })
302                }
303            }
304        }
305    }
306    impl<T> Clone for WallGuardServer<T> {
307        fn clone(&self) -> Self {
308            let inner = self.inner.clone();
309            Self {
310                inner,
311                accept_compression_encodings: self.accept_compression_encodings,
312                send_compression_encodings: self.send_compression_encodings,
313                max_decoding_message_size: self.max_decoding_message_size,
314                max_encoding_message_size: self.max_encoding_message_size,
315            }
316        }
317    }
318    /// Generated gRPC service name
319    pub const SERVICE_NAME: &str = "wallguard_service.WallGuard";
320    impl<T> tonic::server::NamedService for WallGuardServer<T> {
321        const NAME: &'static str = SERVICE_NAME;
322    }
323}