mikufans_proto_intl/
bilibili.broadcast.v2.rs

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