1#[derive(Clone, Copy, PartialEq, ::prost::Message)]
4pub struct AppEventMessage {
5 #[prost(enumeration = "AppEvent", tag = "1")]
7 pub event_type: i32,
8 #[prost(int64, tag = "2")]
10 pub timestamp: i64,
11}
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
14#[repr(i32)]
15pub enum AppEvent {
16 Unknown = 0,
18 Visible = 1,
20 Invisible = 2,
22 HomePage = 3,
24 ColdStart = 4,
26}
27impl AppEvent {
28 pub fn as_str_name(&self) -> &'static str {
33 match self {
34 Self::Unknown => "AppEventUnknown",
35 Self::Visible => "AppEventVisible",
36 Self::Invisible => "AppEventInvisible",
37 Self::HomePage => "AppEventHomePage",
38 Self::ColdStart => "AppEventColdStart",
39 }
40 }
41 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
43 match value {
44 "AppEventUnknown" => Some(Self::Unknown),
45 "AppEventVisible" => Some(Self::Visible),
46 "AppEventInvisible" => Some(Self::Invisible),
47 "AppEventHomePage" => Some(Self::HomePage),
48 "AppEventColdStart" => Some(Self::ColdStart),
49 _ => None,
50 }
51 }
52}
53pub mod b_group_client {
55 #![allow(
56 unused_variables,
57 dead_code,
58 missing_docs,
59 clippy::wildcard_imports,
60 clippy::let_unit_value,
61 )]
62 use tonic::codegen::*;
63 use tonic::codegen::http::Uri;
64 #[derive(Debug, Clone)]
66 pub struct BGroupClient<T> {
67 inner: tonic::client::Grpc<T>,
68 }
69 impl<T> BGroupClient<T>
70 where
71 T: tonic::client::GrpcService<tonic::body::BoxBody>,
72 T::Error: Into<StdError>,
73 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
74 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
75 {
76 pub fn new(inner: T) -> Self {
77 let inner = tonic::client::Grpc::new(inner);
78 Self { inner }
79 }
80 pub fn with_origin(inner: T, origin: Uri) -> Self {
81 let inner = tonic::client::Grpc::with_origin(inner, origin);
82 Self { inner }
83 }
84 pub fn with_interceptor<F>(
85 inner: T,
86 interceptor: F,
87 ) -> BGroupClient<InterceptedService<T, F>>
88 where
89 F: tonic::service::Interceptor,
90 T::ResponseBody: Default,
91 T: tonic::codegen::Service<
92 http::Request<tonic::body::BoxBody>,
93 Response = http::Response<
94 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
95 >,
96 >,
97 <T as tonic::codegen::Service<
98 http::Request<tonic::body::BoxBody>,
99 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
100 {
101 BGroupClient::new(InterceptedService::new(inner, interceptor))
102 }
103 #[must_use]
108 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
109 self.inner = self.inner.send_compressed(encoding);
110 self
111 }
112 #[must_use]
114 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
115 self.inner = self.inner.accept_compressed(encoding);
116 self
117 }
118 #[must_use]
122 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
123 self.inner = self.inner.max_decoding_message_size(limit);
124 self
125 }
126 #[must_use]
130 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
131 self.inner = self.inner.max_encoding_message_size(limit);
132 self
133 }
134 pub async fn app_event_stream(
136 &mut self,
137 request: impl tonic::IntoRequest<super::AppEventMessage>,
138 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
139 self.inner
140 .ready()
141 .await
142 .map_err(|e| {
143 tonic::Status::unknown(
144 format!("Service was not ready: {}", e.into()),
145 )
146 })?;
147 let codec = tonic::codec::ProstCodec::default();
148 let path = http::uri::PathAndQuery::from_static(
149 "/bilibili.broadcast.message.bgroup.BGroup/AppEventStream",
150 );
151 let mut req = request.into_request();
152 req.extensions_mut()
153 .insert(
154 GrpcMethod::new(
155 "bilibili.broadcast.message.bgroup.BGroup",
156 "AppEventStream",
157 ),
158 );
159 self.inner.unary(req, path, codec).await
160 }
161 }
162}
163pub mod b_group_server {
165 #![allow(
166 unused_variables,
167 dead_code,
168 missing_docs,
169 clippy::wildcard_imports,
170 clippy::let_unit_value,
171 )]
172 use tonic::codegen::*;
173 #[async_trait]
175 pub trait BGroup: std::marker::Send + std::marker::Sync + 'static {
176 async fn app_event_stream(
178 &self,
179 request: tonic::Request<super::AppEventMessage>,
180 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
181 }
182 #[derive(Debug)]
184 pub struct BGroupServer<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> BGroupServer<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 #[must_use]
215 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
216 self.accept_compression_encodings.enable(encoding);
217 self
218 }
219 #[must_use]
221 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
222 self.send_compression_encodings.enable(encoding);
223 self
224 }
225 #[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 #[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 BGroupServer<T>
243 where
244 T: BGroup,
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.bgroup.BGroup/AppEventStream" => {
260 #[allow(non_camel_case_types)]
261 struct AppEventStreamSvc<T: BGroup>(pub Arc<T>);
262 impl<T: BGroup> tonic::server::UnaryService<super::AppEventMessage>
263 for AppEventStreamSvc<T> {
264 type Response = ();
265 type Future = BoxFuture<
266 tonic::Response<Self::Response>,
267 tonic::Status,
268 >;
269 fn call(
270 &mut self,
271 request: tonic::Request<super::AppEventMessage>,
272 ) -> Self::Future {
273 let inner = Arc::clone(&self.0);
274 let fut = async move {
275 <T as BGroup>::app_event_stream(&inner, request).await
276 };
277 Box::pin(fut)
278 }
279 }
280 let accept_compression_encodings = self.accept_compression_encodings;
281 let send_compression_encodings = self.send_compression_encodings;
282 let max_decoding_message_size = self.max_decoding_message_size;
283 let max_encoding_message_size = self.max_encoding_message_size;
284 let inner = self.inner.clone();
285 let fut = async move {
286 let method = AppEventStreamSvc(inner);
287 let codec = tonic::codec::ProstCodec::default();
288 let mut grpc = tonic::server::Grpc::new(codec)
289 .apply_compression_config(
290 accept_compression_encodings,
291 send_compression_encodings,
292 )
293 .apply_max_message_size_config(
294 max_decoding_message_size,
295 max_encoding_message_size,
296 );
297 let res = grpc.unary(method, req).await;
298 Ok(res)
299 };
300 Box::pin(fut)
301 }
302 _ => {
303 Box::pin(async move {
304 let mut response = http::Response::new(empty_body());
305 let headers = response.headers_mut();
306 headers
307 .insert(
308 tonic::Status::GRPC_STATUS,
309 (tonic::Code::Unimplemented as i32).into(),
310 );
311 headers
312 .insert(
313 http::header::CONTENT_TYPE,
314 tonic::metadata::GRPC_CONTENT_TYPE,
315 );
316 Ok(response)
317 })
318 }
319 }
320 }
321 }
322 impl<T> Clone for BGroupServer<T> {
323 fn clone(&self) -> Self {
324 let inner = self.inner.clone();
325 Self {
326 inner,
327 accept_compression_encodings: self.accept_compression_encodings,
328 send_compression_encodings: self.send_compression_encodings,
329 max_decoding_message_size: self.max_decoding_message_size,
330 max_encoding_message_size: self.max_encoding_message_size,
331 }
332 }
333 }
334 pub const SERVICE_NAME: &str = "bilibili.broadcast.message.bgroup.BGroup";
336 impl<T> tonic::server::NamedService for BGroupServer<T> {
337 const NAME: &'static str = SERVICE_NAME;
338 }
339}