#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Arc {
#[prost(string, tag = "1")]
pub date: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub stat: ::core::option::Option<Stat>,
#[prost(string, tag = "3")]
pub cover: ::prost::alloc::string::String,
#[prost(int64, tag = "4")]
pub duration: i64,
#[prost(int64, tag = "5")]
pub aid: i64,
#[prost(int64, tag = "6")]
pub cid: i64,
#[prost(enumeration = "ArcState", tag = "7")]
pub state: i32,
}
impl ::prost::Name for Arc {
const NAME: &'static str = "Arc";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.Arc".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.Arc".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Button {
#[prost(string, tag = "1")]
pub light_icon: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub dark_icon: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub url: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub text: ::prost::alloc::string::String,
}
impl ::prost::Name for Button {
const NAME: &'static str = "Button";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.Button".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.Button".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardMore {
#[prost(message, optional, tag = "1")]
pub button: ::core::option::Option<Button>,
}
impl ::prost::Name for CardMore {
const NAME: &'static str = "CardMore";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.CardMore".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.CardMore".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardOpus {
#[prost(message, optional, tag = "1")]
pub word_paragraph: ::core::option::Option<super::super::dynamic::v2::Paragraph>,
#[prost(string, tag = "2")]
pub cover: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub url: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub stat_title: ::core::option::Option<SubTitleWithStat>,
#[prost(message, optional, tag = "5")]
pub stat: ::core::option::Option<Stat>,
#[prost(string, tag = "6")]
pub date: ::prost::alloc::string::String,
#[prost(int64, tag = "7")]
pub dyn_id: i64,
#[prost(bool, tag = "8")]
pub has_share: bool,
#[prost(enumeration = "OpusState", tag = "9")]
pub state: i32,
}
impl ::prost::Name for CardOpus {
const NAME: &'static str = "CardOpus";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.CardOpus".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.CardOpus".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardPubGuide {
#[prost(message, optional, tag = "1")]
pub title: ::core::option::Option<Title>,
#[prost(message, optional, tag = "2")]
pub button: ::core::option::Option<Button>,
#[prost(message, repeated, tag = "3")]
pub material: ::prost::alloc::vec::Vec<PubGuideMaterial>,
#[prost(message, optional, tag = "4")]
pub more_button: ::core::option::Option<Button>,
}
impl ::prost::Name for CardPubGuide {
const NAME: &'static str = "CardPubGuide";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.CardPubGuide".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.CardPubGuide".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardUgc {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub title_color: ::core::option::Option<Color>,
#[prost(message, optional, tag = "5")]
pub arc: ::core::option::Option<Arc>,
#[prost(string, tag = "6")]
pub url: ::prost::alloc::string::String,
#[prost(bool, tag = "7")]
pub has_share: bool,
#[prost(string, tag = "8")]
pub archive_video_audit_json: ::prost::alloc::string::String,
#[prost(oneof = "card_ugc::Subtitle", tags = "3, 4")]
pub subtitle: ::core::option::Option<card_ugc::Subtitle>,
}
pub mod card_ugc {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Subtitle {
#[prost(message, tag = "3")]
ButtonTitle(super::SubTitleWithButton),
#[prost(message, tag = "4")]
StatTitle(super::SubTitleWithStat),
}
}
impl ::prost::Name for CardUgc {
const NAME: &'static str = "CardUGC";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.CardUGC".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.CardUGC".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Color {
#[prost(string, tag = "1")]
pub light_color: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub dark_color: ::prost::alloc::string::String,
}
impl ::prost::Name for Color {
const NAME: &'static str = "Color";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.Color".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.Color".into()
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeviceFeatureReq {}
impl ::prost::Name for DeviceFeatureReq {
const NAME: &'static str = "DeviceFeatureReq";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.DeviceFeatureReq".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.DeviceFeatureReq".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeviceFeatureResp {
#[prost(string, tag = "1")]
pub action_data: ::prost::alloc::string::String,
}
impl ::prost::Name for DeviceFeatureResp {
const NAME: &'static str = "DeviceFeatureResp";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.DeviceFeatureResp".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.DeviceFeatureResp".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DisplayReportReq {
#[prost(message, repeated, tag = "1")]
pub content: ::prost::alloc::vec::Vec<display_report_req::ReportContent>,
}
pub mod display_report_req {
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ReportContent {
#[prost(int64, tag = "1")]
pub times: i64,
#[prost(enumeration = "super::DisplayPos", tag = "2")]
pub pos: i32,
}
impl ::prost::Name for ReportContent {
const NAME: &'static str = "ReportContent";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.DisplayReportReq.ReportContent".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.DisplayReportReq.ReportContent".into()
}
}
}
impl ::prost::Name for DisplayReportReq {
const NAME: &'static str = "DisplayReportReq";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.DisplayReportReq".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.DisplayReportReq".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubCard {
#[prost(enumeration = "CardType", tag = "5")]
pub r#type: i32,
#[prost(oneof = "pub_card::Card", tags = "1, 2, 3, 4")]
pub card: ::core::option::Option<pub_card::Card>,
}
pub mod pub_card {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Card {
#[prost(message, tag = "1")]
PubGuide(::prost::alloc::boxed::Box<super::CardPubGuide>),
#[prost(message, tag = "2")]
Ugc(::prost::alloc::boxed::Box<super::CardUgc>),
#[prost(message, tag = "3")]
Opus(::prost::alloc::boxed::Box<super::CardOpus>),
#[prost(message, tag = "4")]
More(::prost::alloc::boxed::Box<super::CardMore>),
}
}
impl ::prost::Name for PubCard {
const NAME: &'static str = "PubCard";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.PubCard".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.PubCard".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubGuideMaterial {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(message, optional, tag = "2")]
pub title: ::core::option::Option<Title>,
#[prost(string, tag = "3")]
pub cover: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub url: ::prost::alloc::string::String,
}
impl ::prost::Name for PubGuideMaterial {
const NAME: &'static str = "PubGuideMaterial";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.PubGuideMaterial".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.PubGuideMaterial".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubModuleReq {
#[prost(int64, tag = "1")]
pub user_original_state: i64,
#[prost(int64, repeated, tag = "2")]
pub dyn_ids: ::prost::alloc::vec::Vec<i64>,
#[prost(int64, tag = "3")]
pub card_num: i64,
}
impl ::prost::Name for PubModuleReq {
const NAME: &'static str = "PubModuleReq";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.PubModuleReq".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.PubModuleReq".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubModuleResp {
#[prost(message, repeated, tag = "1")]
pub pub_card: ::prost::alloc::vec::Vec<PubCard>,
}
impl ::prost::Name for PubModuleResp {
const NAME: &'static str = "PubModuleResp";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.PubModuleResp".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.PubModuleResp".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Stat {
#[prost(string, tag = "1")]
pub play_icon: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub play: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub like_icon: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub like: ::prost::alloc::string::String,
}
impl ::prost::Name for Stat {
const NAME: &'static str = "Stat";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.Stat".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.Stat".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubTitleWithButton {
#[prost(string, tag = "1")]
pub icon: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub url: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub background_color: ::core::option::Option<Color>,
#[prost(string, tag = "4")]
pub text: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub text_color: ::core::option::Option<Color>,
}
impl ::prost::Name for SubTitleWithButton {
const NAME: &'static str = "SubTitleWithButton";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.SubTitleWithButton".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.SubTitleWithButton".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubTitleWithStat {
#[prost(string, repeated, tag = "1")]
pub icon: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
}
impl ::prost::Name for SubTitleWithStat {
const NAME: &'static str = "SubTitleWithStat";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.SubTitleWithStat".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.SubTitleWithStat".into()
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Title {
#[prost(string, tag = "1")]
pub main: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub sub: ::prost::alloc::string::String,
}
impl ::prost::Name for Title {
const NAME: &'static str = "Title";
const PACKAGE: &'static str = "bilibili.app.mine.v1";
fn full_name() -> ::prost::alloc::string::String {
"bilibili.app.mine.v1.Title".into()
}
fn type_url() -> ::prost::alloc::string::String {
"/bilibili.app.mine.v1.Title".into()
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ArcState {
StateUnknown = 0,
Open = 1,
Orange = 2,
Wait = 3,
Recicle = 4,
Lock = 5,
Fixed = 6,
UserDelay = 7,
FastPub = 8,
XcodeFail = 9,
}
impl ArcState {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::StateUnknown => "STATE_UNKNOWN",
Self::Open => "OPEN",
Self::Orange => "ORANGE",
Self::Wait => "WAIT",
Self::Recicle => "RECICLE",
Self::Lock => "LOCK",
Self::Fixed => "FIXED",
Self::UserDelay => "USER_DELAY",
Self::FastPub => "FAST_PUB",
Self::XcodeFail => "XCODE_FAIL",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATE_UNKNOWN" => Some(Self::StateUnknown),
"OPEN" => Some(Self::Open),
"ORANGE" => Some(Self::Orange),
"WAIT" => Some(Self::Wait),
"RECICLE" => Some(Self::Recicle),
"LOCK" => Some(Self::Lock),
"FIXED" => Some(Self::Fixed),
"USER_DELAY" => Some(Self::UserDelay),
"FAST_PUB" => Some(Self::FastPub),
"XCODE_FAIL" => Some(Self::XcodeFail),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CardType {
CardUnknown = 0,
Pubguide = 1,
Ugc = 2,
Opus = 3,
More = 4,
}
impl CardType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::CardUnknown => "CARD_UNKNOWN",
Self::Pubguide => "PUBGUIDE",
Self::Ugc => "UGC",
Self::Opus => "OPUS",
Self::More => "MORE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"CARD_UNKNOWN" => Some(Self::CardUnknown),
"PUBGUIDE" => Some(Self::Pubguide),
"UGC" => Some(Self::Ugc),
"OPUS" => Some(Self::Opus),
"MORE" => Some(Self::More),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DisplayPos {
UnknownDisplaytype = 0,
VipButtonStatic = 1,
VipButtonDynamic = 2,
VipButtonBirthday = 3,
VipBackground = 4,
}
impl DisplayPos {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::UnknownDisplaytype => "UNKNOWN_DISPLAYTYPE",
Self::VipButtonStatic => "VIP_BUTTON_STATIC",
Self::VipButtonDynamic => "VIP_BUTTON_DYNAMIC",
Self::VipButtonBirthday => "VIP_BUTTON_BIRTHDAY",
Self::VipBackground => "VIP_BACKGROUND",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN_DISPLAYTYPE" => Some(Self::UnknownDisplaytype),
"VIP_BUTTON_STATIC" => Some(Self::VipButtonStatic),
"VIP_BUTTON_DYNAMIC" => Some(Self::VipButtonDynamic),
"VIP_BUTTON_BIRTHDAY" => Some(Self::VipButtonBirthday),
"VIP_BACKGROUND" => Some(Self::VipBackground),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OpusState {
OpusUnknown = 0,
OpusOpen = 1,
OpusNoForward = 2,
}
impl OpusState {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::OpusUnknown => "OPUS_UNKNOWN",
Self::OpusOpen => "OPUS_OPEN",
Self::OpusNoForward => "OPUS_NO_FORWARD",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OPUS_UNKNOWN" => Some(Self::OpusUnknown),
"OPUS_OPEN" => Some(Self::OpusOpen),
"OPUS_NO_FORWARD" => Some(Self::OpusNoForward),
_ => None,
}
}
}
#[cfg(feature = "feat-enable-generated-client")]
pub mod mine_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct MineClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> MineClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> MineClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
MineClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn device_feature(
&mut self,
request: impl tonic::IntoRequest<super::DeviceFeatureReq>,
) -> std::result::Result<
tonic::Response<super::DeviceFeatureResp>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/bilibili.app.mine.v1.Mine/DeviceFeature",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("bilibili.app.mine.v1.Mine", "DeviceFeature"));
self.inner.unary(req, path, codec).await
}
pub async fn display_report(
&mut self,
request: impl tonic::IntoRequest<super::DisplayReportReq>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/bilibili.app.mine.v1.Mine/DisplayReport",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("bilibili.app.mine.v1.Mine", "DisplayReport"));
self.inner.unary(req, path, codec).await
}
pub async fn pub_module(
&mut self,
request: impl tonic::IntoRequest<super::PubModuleReq>,
) -> std::result::Result<tonic::Response<super::PubModuleResp>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/bilibili.app.mine.v1.Mine/PubModule",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("bilibili.app.mine.v1.Mine", "PubModule"));
self.inner.unary(req, path, codec).await
}
}
}
#[cfg(feature = "feat-enable-generated-server")]
pub mod mine_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait Mine: std::marker::Send + std::marker::Sync + 'static {
async fn device_feature(
&self,
request: tonic::Request<super::DeviceFeatureReq>,
) -> std::result::Result<
tonic::Response<super::DeviceFeatureResp>,
tonic::Status,
>;
async fn display_report(
&self,
request: tonic::Request<super::DisplayReportReq>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
async fn pub_module(
&self,
request: tonic::Request<super::PubModuleReq>,
) -> std::result::Result<tonic::Response<super::PubModuleResp>, tonic::Status>;
}
#[derive(Debug)]
pub struct MineServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> MineServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for MineServer<T>
where
T: Mine,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/bilibili.app.mine.v1.Mine/DeviceFeature" => {
#[allow(non_camel_case_types)]
struct DeviceFeatureSvc<T: Mine>(pub Arc<T>);
impl<T: Mine> tonic::server::UnaryService<super::DeviceFeatureReq>
for DeviceFeatureSvc<T> {
type Response = super::DeviceFeatureResp;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DeviceFeatureReq>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Mine>::device_feature(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = DeviceFeatureSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/bilibili.app.mine.v1.Mine/DisplayReport" => {
#[allow(non_camel_case_types)]
struct DisplayReportSvc<T: Mine>(pub Arc<T>);
impl<T: Mine> tonic::server::UnaryService<super::DisplayReportReq>
for DisplayReportSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DisplayReportReq>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Mine>::display_report(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = DisplayReportSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/bilibili.app.mine.v1.Mine/PubModule" => {
#[allow(non_camel_case_types)]
struct PubModuleSvc<T: Mine>(pub Arc<T>);
impl<T: Mine> tonic::server::UnaryService<super::PubModuleReq>
for PubModuleSvc<T> {
type Response = super::PubModuleResp;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::PubModuleReq>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Mine>::pub_module(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = PubModuleSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for MineServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "bilibili.app.mine.v1.Mine";
impl<T> tonic::server::NamedService for MineServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}