mikufans_proto_intl/
bilibili.broadcast.message.fawkes.rs

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