diff --git a/Cargo.lock b/Cargo.lock index 6c41c91..637bcfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,7 +371,7 @@ dependencies = [ [[package]] name = "fav_core" -version = "0.0.1" +version = "0.0.2" dependencies = [ "bitflags 2.4.2", "fav_derive", diff --git a/Cargo.toml b/Cargo.toml index fb92dae..7faa23d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "fav_core", "fav_utils_old", "fav_utils", - "fav_derive" + "fav_derive", ] resolver = "2" @@ -21,9 +21,9 @@ repository = "https://github.com/kingwingfly/fav" documentation = "" [workspace.dependencies] -fav_core = { path = "fav_core" } +fav_core = { path = "fav_core", version = ">=0.0.1" } fav_derive = { path = "fav_derive", version = ">=0.0.1" } -fav_utils = { path = "fav_utils" } +fav_utils = { path = "fav_utils", version = ">=0.0.1" } fav_cli = { path = "fav_cli" } fav_utils_old = { path = "fav_utils_old" } diff --git a/fav_cli/Cargo.toml b/fav_cli/Cargo.toml index 382ecaf..724b703 100644 --- a/fav_cli/Cargo.toml +++ b/fav_cli/Cargo.toml @@ -1,13 +1,12 @@ [package] name = "fav_cli" -version.workspace= true +version.workspace = true authors.workspace = true description = "Fav's CLI, helping persist the remote source. Repo: https://github.com/kingwingfly/fav" license.workspace = true edition.workspace = true repository.workspace = true documentation = "https://docs.rs/fav_cli" -publish = false [package.metadata.docs.rs] all-features = true diff --git a/fav_core/Cargo.toml b/fav_core/Cargo.toml index 92fdb54..5cb21ea 100644 --- a/fav_core/Cargo.toml +++ b/fav_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fav_core" -version = "0.0.1" +version = "0.0.2" authors.workspace = true description = "Fav's core crate; A collection of traits." license.workspace = true diff --git a/fav_core/build.rs b/fav_core/build.rs index 2865192..9b36152 100644 --- a/fav_core/build.rs +++ b/fav_core/build.rs @@ -13,9 +13,14 @@ fn main() -> Result<(), Box> { .pure() .includes(["proto"]) .inputs(["proto/data.proto"]) - .out_dir("src/test_utils/proto") + .cargo_out_dir("proto") .run() - .ok(); // Just omit the err since crates.io build on a readonly system + .unwrap(); + let path = std::path::PathBuf::from(std::env::var("OUT_DIR")?).join("proto/data.rs"); + let gen = std::fs::read_to_string(&path)?; + let processed = gen.replace("#!", "//").replace("//!", "//"); + std::fs::write(path, processed)?; println!("cargo:return-if-changed=proto"); + println!("cargo:return-if-changed=build.rs"); Ok(()) } diff --git a/fav_core/src/test_utils/data.rs b/fav_core/src/test_utils/data.rs new file mode 100644 index 0000000..8dc6648 --- /dev/null +++ b/fav_core/src/test_utils/data.rs @@ -0,0 +1,18 @@ +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `data.proto` +include!(concat!(env!("OUT_DIR"), "/proto/data.rs")); diff --git a/fav_core/src/test_utils/impls.rs b/fav_core/src/test_utils/impls.rs index 4f30360..34efa60 100644 --- a/fav_core/src/test_utils/impls.rs +++ b/fav_core/src/test_utils/impls.rs @@ -3,8 +3,7 @@ use crate::{api::DefaultApiKind, prelude::*}; #[cfg(not(test))] use fav_core::{api::DefaultApiKind, prelude::*}; -use super::data::{App, Conf, TestRes, TestSet, TestSets}; -use std::future::Future; +use super::data::{App, TestRes, TestSet, TestSets}; impl HttpConfig for App { fn headers(&self) -> reqwest::header::HeaderMap { @@ -23,7 +22,7 @@ impl HttpConfig for App { impl ApiProvider for App { type ApiKind = DefaultApiKind; - fn api(&self, api_kind: Self::ApiKind) -> &dyn Api { + fn api(&self, _: Self::ApiKind) -> &dyn Api { todo!() } } @@ -41,11 +40,11 @@ impl AuthOps for App { impl ResOps for App { type Res = TestRes; - async fn fetch_res(&self, resource: &mut Self::Res) -> FavCoreResult<()> { + async fn fetch_res(&self, _: &mut Self::Res) -> FavCoreResult<()> { todo!() } - async fn pull_res(&self, resource: &mut Self::Res) -> FavCoreResult<()> { + async fn pull_res(&self, _: &mut Self::Res) -> FavCoreResult<()> { todo!() } } @@ -53,7 +52,7 @@ impl ResOps for App { impl SetOps for App { type Set = TestSet; - async fn fetch_set(&self, set: &mut Self::Set) -> FavCoreResult<()> { + async fn fetch_set(&self, _: &mut Self::Set) -> FavCoreResult<()> { todo!() } } diff --git a/fav_core/src/test_utils/mod.rs b/fav_core/src/test_utils/mod.rs index ef09019..fde7085 100644 --- a/fav_core/src/test_utils/mod.rs +++ b/fav_core/src/test_utils/mod.rs @@ -1,7 +1,2 @@ -#![allow(unused)] - +pub mod data; mod impls; -mod proto; - -pub use impls::*; -pub use proto::*; diff --git a/fav_core/src/test_utils/proto/data.rs b/fav_core/src/test_utils/proto/data.rs deleted file mode 100644 index 4666422..0000000 --- a/fav_core/src/test_utils/proto/data.rs +++ /dev/null @@ -1,1182 +0,0 @@ -// This file is generated by rust-protobuf 3.3.0. Do not edit -// .proto file is parsed by pure -// @generated - -// https://github.com/rust-lang/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![allow(unused_attributes)] -#![cfg_attr(rustfmt, rustfmt::skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unused_results)] -#![allow(unused_mut)] - -//! Generated file from `data.proto` - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_3_0; - -// @@protoc_insertion_point(message:data.Msg) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct Msg { - // special fields - // @@protoc_insertion_point(special_field:data.Msg.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a Msg { - fn default() -> &'a Msg { - ::default_instance() - } -} - -impl Msg { - pub fn new() -> Msg { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(0); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "Msg", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for Msg { - const NAME: &'static str = "Msg"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> Msg { - Msg::new() - } - - fn clear(&mut self) { - self.special_fields.clear(); - } - - fn default_instance() -> &'static Msg { - static instance: Msg = Msg { - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for Msg { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("Msg").unwrap()).clone() - } -} - -impl ::std::fmt::Display for Msg { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Msg { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.Conf) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct Conf { - // message fields - // @@protoc_insertion_point(field:data.Conf.cookies) - pub cookies: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - // special fields - // @@protoc_insertion_point(special_field:data.Conf.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a Conf { - fn default() -> &'a Conf { - ::default_instance() - } -} - -impl Conf { - pub fn new() -> Conf { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(1); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_map_simpler_accessor::<_, _, _>( - "cookies", - |m: &Conf| { &m.cookies }, - |m: &mut Conf| { &mut m.cookies }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "Conf", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for Conf { - const NAME: &'static str = "Conf"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => { - let len = is.read_raw_varint32()?; - let old_limit = is.push_limit(len as u64)?; - let mut key = ::std::default::Default::default(); - let mut value = ::std::default::Default::default(); - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => key = is.read_string()?, - 18 => value = is.read_string()?, - _ => ::protobuf::rt::skip_field_for_tag(tag, is)?, - }; - } - is.pop_limit(old_limit); - self.cookies.insert(key, value); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - for (k, v) in &self.cookies { - let mut entry_size = 0; - entry_size += ::protobuf::rt::string_size(1, &k); - entry_size += ::protobuf::rt::string_size(2, &v); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(entry_size) + entry_size - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - for (k, v) in &self.cookies { - let mut entry_size = 0; - entry_size += ::protobuf::rt::string_size(1, &k); - entry_size += ::protobuf::rt::string_size(2, &v); - os.write_raw_varint32(10)?; // Tag. - os.write_raw_varint32(entry_size as u32)?; - os.write_string(1, &k)?; - os.write_string(2, &v)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> Conf { - Conf::new() - } - - fn clear(&mut self) { - self.cookies.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static Conf { - static instance: ::protobuf::rt::Lazy = ::protobuf::rt::Lazy::new(); - instance.get(Conf::new) - } -} - -impl ::protobuf::MessageFull for Conf { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("Conf").unwrap()).clone() - } -} - -impl ::std::fmt::Display for Conf { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Conf { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.App) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct App { - // special fields - // @@protoc_insertion_point(special_field:data.App.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a App { - fn default() -> &'a App { - ::default_instance() - } -} - -impl App { - pub fn new() -> App { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(0); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "App", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for App { - const NAME: &'static str = "App"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> App { - App::new() - } - - fn clear(&mut self) { - self.special_fields.clear(); - } - - fn default_instance() -> &'static App { - static instance: App = App { - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for App { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("App").unwrap()).clone() - } -} - -impl ::std::fmt::Display for App { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for App { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.TestSets) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct TestSets { - // message fields - // @@protoc_insertion_point(field:data.TestSets.sets) - pub sets: ::std::vec::Vec, - // special fields - // @@protoc_insertion_point(special_field:data.TestSets.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a TestSets { - fn default() -> &'a TestSets { - ::default_instance() - } -} - -impl TestSets { - pub fn new() -> TestSets { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(1); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( - "sets", - |m: &TestSets| { &m.sets }, - |m: &mut TestSets| { &mut m.sets }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "TestSets", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for TestSets { - const NAME: &'static str = "TestSets"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => { - self.sets.push(is.read_message()?); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - for value in &self.sets { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - for v in &self.sets { - ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> TestSets { - TestSets::new() - } - - fn clear(&mut self) { - self.sets.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static TestSets { - static instance: TestSets = TestSets { - sets: ::std::vec::Vec::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for TestSets { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("TestSets").unwrap()).clone() - } -} - -impl ::std::fmt::Display for TestSets { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for TestSets { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.TestSet) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct TestSet { - // message fields - // @@protoc_insertion_point(field:data.TestSet.id) - pub id: i32, - // @@protoc_insertion_point(field:data.TestSet.title) - pub title: ::std::string::String, - // @@protoc_insertion_point(field:data.TestSet.set) - pub set: ::std::vec::Vec, - // @@protoc_insertion_point(field:data.TestSet.status) - pub status: i32, - // special fields - // @@protoc_insertion_point(special_field:data.TestSet.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a TestSet { - fn default() -> &'a TestSet { - ::default_instance() - } -} - -impl TestSet { - pub fn new() -> TestSet { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(4); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "id", - |m: &TestSet| { &m.id }, - |m: &mut TestSet| { &mut m.id }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &TestSet| { &m.title }, - |m: &mut TestSet| { &mut m.title }, - )); - fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( - "set", - |m: &TestSet| { &m.set }, - |m: &mut TestSet| { &mut m.set }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "status", - |m: &TestSet| { &m.status }, - |m: &mut TestSet| { &mut m.status }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "TestSet", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for TestSet { - const NAME: &'static str = "TestSet"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.id = is.read_int32()?; - }, - 18 => { - self.title = is.read_string()?; - }, - 26 => { - self.set.push(is.read_message()?); - }, - 32 => { - self.status = is.read_int32()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::int32_size(1, self.id); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - for value in &self.set { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - }; - if self.status != 0 { - my_size += ::protobuf::rt::int32_size(4, self.status); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.id != 0 { - os.write_int32(1, self.id)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - for v in &self.set { - ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; - }; - if self.status != 0 { - os.write_int32(4, self.status)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> TestSet { - TestSet::new() - } - - fn clear(&mut self) { - self.id = 0; - self.title.clear(); - self.set.clear(); - self.status = 0; - self.special_fields.clear(); - } - - fn default_instance() -> &'static TestSet { - static instance: TestSet = TestSet { - id: 0, - title: ::std::string::String::new(), - set: ::std::vec::Vec::new(), - status: 0, - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for TestSet { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("TestSet").unwrap()).clone() - } -} - -impl ::std::fmt::Display for TestSet { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for TestSet { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.TestRes) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct TestRes { - // message fields - // @@protoc_insertion_point(field:data.TestRes.id) - pub id: i32, - // @@protoc_insertion_point(field:data.TestRes.title) - pub title: ::std::string::String, - // @@protoc_insertion_point(field:data.TestRes.status) - pub status: i32, - // special fields - // @@protoc_insertion_point(special_field:data.TestRes.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a TestRes { - fn default() -> &'a TestRes { - ::default_instance() - } -} - -impl TestRes { - pub fn new() -> TestRes { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(3); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "id", - |m: &TestRes| { &m.id }, - |m: &mut TestRes| { &mut m.id }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &TestRes| { &m.title }, - |m: &mut TestRes| { &mut m.title }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "status", - |m: &TestRes| { &m.status }, - |m: &mut TestRes| { &mut m.status }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "TestRes", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for TestRes { - const NAME: &'static str = "TestRes"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.id = is.read_int32()?; - }, - 18 => { - self.title = is.read_string()?; - }, - 24 => { - self.status = is.read_int32()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::int32_size(1, self.id); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - if self.status != 0 { - my_size += ::protobuf::rt::int32_size(3, self.status); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.id != 0 { - os.write_int32(1, self.id)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - if self.status != 0 { - os.write_int32(3, self.status)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> TestRes { - TestRes::new() - } - - fn clear(&mut self) { - self.id = 0; - self.title.clear(); - self.status = 0; - self.special_fields.clear(); - } - - fn default_instance() -> &'static TestRes { - static instance: TestRes = TestRes { - id: 0, - title: ::std::string::String::new(), - status: 0, - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for TestRes { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("TestRes").unwrap()).clone() - } -} - -impl ::std::fmt::Display for TestRes { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for TestRes { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.StatusTest) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct StatusTest { - // message fields - // @@protoc_insertion_point(field:data.StatusTest.id) - pub id: i32, - // @@protoc_insertion_point(field:data.StatusTest.title) - pub title: ::std::string::String, - // @@protoc_insertion_point(field:data.StatusTest.status) - pub status: i32, - // special fields - // @@protoc_insertion_point(special_field:data.StatusTest.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a StatusTest { - fn default() -> &'a StatusTest { - ::default_instance() - } -} - -impl StatusTest { - pub fn new() -> StatusTest { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(3); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "id", - |m: &StatusTest| { &m.id }, - |m: &mut StatusTest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &StatusTest| { &m.title }, - |m: &mut StatusTest| { &mut m.title }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "status", - |m: &StatusTest| { &m.status }, - |m: &mut StatusTest| { &mut m.status }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "StatusTest", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for StatusTest { - const NAME: &'static str = "StatusTest"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.id = is.read_int32()?; - }, - 18 => { - self.title = is.read_string()?; - }, - 24 => { - self.status = is.read_int32()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::int32_size(1, self.id); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - if self.status != 0 { - my_size += ::protobuf::rt::int32_size(3, self.status); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.id != 0 { - os.write_int32(1, self.id)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - if self.status != 0 { - os.write_int32(3, self.status)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> StatusTest { - StatusTest::new() - } - - fn clear(&mut self) { - self.id = 0; - self.title.clear(); - self.status = 0; - self.special_fields.clear(); - } - - fn default_instance() -> &'static StatusTest { - static instance: StatusTest = StatusTest { - id: 0, - title: ::std::string::String::new(), - status: 0, - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for StatusTest { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("StatusTest").unwrap()).clone() - } -} - -impl ::std::fmt::Display for StatusTest { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for StatusTest { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:data.AttrTest) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct AttrTest { - // message fields - // @@protoc_insertion_point(field:data.AttrTest.id) - pub id: i32, - // @@protoc_insertion_point(field:data.AttrTest.title) - pub title: ::std::string::String, - // special fields - // @@protoc_insertion_point(special_field:data.AttrTest.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a AttrTest { - fn default() -> &'a AttrTest { - ::default_instance() - } -} - -impl AttrTest { - pub fn new() -> AttrTest { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(2); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "id", - |m: &AttrTest| { &m.id }, - |m: &mut AttrTest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &AttrTest| { &m.title }, - |m: &mut AttrTest| { &mut m.title }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "AttrTest", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for AttrTest { - const NAME: &'static str = "AttrTest"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.id = is.read_int32()?; - }, - 18 => { - self.title = is.read_string()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::int32_size(1, self.id); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.id != 0 { - os.write_int32(1, self.id)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> AttrTest { - AttrTest::new() - } - - fn clear(&mut self) { - self.id = 0; - self.title.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static AttrTest { - static instance: AttrTest = AttrTest { - id: 0, - title: ::std::string::String::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for AttrTest { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("AttrTest").unwrap()).clone() - } -} - -impl ::std::fmt::Display for AttrTest { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for AttrTest { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\ndata.proto\x12\x04data\"\x05\n\x03Msg\"u\n\x04Conf\x121\n\x07cookies\ - \x18\x01\x20\x03(\x0b2\x17.data.Conf.CookiesEntryR\x07cookies\x1a:\n\x0c\ - CookiesEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05va\ - lue\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\x05\n\x03App\"-\n\x08TestSe\ - ts\x12!\n\x04sets\x18\x01\x20\x03(\x0b2\r.data.TestSetR\x04sets\"h\n\x07\ - TestSet\x12\x0e\n\x02id\x18\x01\x20\x01(\x05R\x02id\x12\x14\n\x05title\ - \x18\x02\x20\x01(\tR\x05title\x12\x1f\n\x03set\x18\x03\x20\x03(\x0b2\r.d\ - ata.TestResR\x03set\x12\x16\n\x06status\x18\x04\x20\x01(\x05R\x06status\ - \"G\n\x07TestRes\x12\x0e\n\x02id\x18\x01\x20\x01(\x05R\x02id\x12\x14\n\ - \x05title\x18\x02\x20\x01(\tR\x05title\x12\x16\n\x06status\x18\x03\x20\ - \x01(\x05R\x06status\"J\n\nStatusTest\x12\x0e\n\x02id\x18\x01\x20\x01(\ - \x05R\x02id\x12\x14\n\x05title\x18\x02\x20\x01(\tR\x05title\x12\x16\n\ - \x06status\x18\x03\x20\x01(\x05R\x06status\"0\n\x08AttrTest\x12\x0e\n\ - \x02id\x18\x01\x20\x01(\x05R\x02id\x12\x14\n\x05title\x18\x02\x20\x01(\t\ - R\x05titleb\x06proto3\ -"; - -/// `FileDescriptorProto` object which was a source for this generated file -fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); - file_descriptor_proto_lazy.get(|| { - ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() - }) -} - -/// `FileDescriptor` object which allows dynamic access to files -pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { - static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); - static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); - file_descriptor.get(|| { - let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { - let mut deps = ::std::vec::Vec::with_capacity(0); - let mut messages = ::std::vec::Vec::with_capacity(8); - messages.push(Msg::generated_message_descriptor_data()); - messages.push(Conf::generated_message_descriptor_data()); - messages.push(App::generated_message_descriptor_data()); - messages.push(TestSets::generated_message_descriptor_data()); - messages.push(TestSet::generated_message_descriptor_data()); - messages.push(TestRes::generated_message_descriptor_data()); - messages.push(StatusTest::generated_message_descriptor_data()); - messages.push(AttrTest::generated_message_descriptor_data()); - let mut enums = ::std::vec::Vec::with_capacity(0); - ::protobuf::reflect::GeneratedFileDescriptor::new_generated( - file_descriptor_proto(), - deps, - messages, - enums, - ) - }); - ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) - }) -} diff --git a/fav_core/src/test_utils/proto/mod.rs b/fav_core/src/test_utils/proto/mod.rs deleted file mode 100644 index 4396744..0000000 --- a/fav_core/src/test_utils/proto/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -// @generated - -pub mod data; diff --git a/fav_utils/Cargo.toml b/fav_utils/Cargo.toml index ef52d86..f8daeed 100644 --- a/fav_utils/Cargo.toml +++ b/fav_utils/Cargo.toml @@ -7,7 +7,6 @@ license.workspace = true edition.workspace = true repository.workspace = true documentation = "https://docs.rs/fav_utils" -publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/fav_utils/build.rs b/fav_utils/build.rs index a73691a..3db4a80 100644 --- a/fav_utils/build.rs +++ b/fav_utils/build.rs @@ -15,10 +15,14 @@ fn main() -> Result<(), Box> { .pure() .includes(["proto"]) .inputs(["proto/bili.proto"]) - .out_dir("src/proto") + .cargo_out_dir("proto") .customize_callback(MyCustomizeCallback) .run() - .ok(); // Just omit the err since crates.io build on a readonly system + .unwrap(); + let path = std::path::PathBuf::from(std::env::var("OUT_DIR")?).join("proto/bili.rs"); + let gen = std::fs::read_to_string(&path)?; + let processed = gen.replace("#!", "//").replace("//!", "//"); + std::fs::write(path, processed)?; println!("cargo:return-if-changed=proto"); println!("cargo:return-if-changed=build.rs"); Ok(()) diff --git a/fav_utils/src/bili/api.rs b/fav_utils/src/bili/api.rs index a3a33ff..b9c192b 100644 --- a/fav_utils/src/bili/api.rs +++ b/fav_utils/src/bili/api.rs @@ -1,4 +1,5 @@ -use crate::{proto::bili::Bili, utils::time::timestamp_sc}; +use super::Bili; +use crate::utils::time::timestamp_sc; use fav_core::api::{Api, ApiProvider}; impl ApiProvider for Bili { diff --git a/fav_utils/src/bili/config.rs b/fav_utils/src/bili/config.rs index ac52c0e..2a971c5 100644 --- a/fav_utils/src/bili/config.rs +++ b/fav_utils/src/bili/config.rs @@ -1,4 +1,4 @@ -use crate::proto::bili::Bili; +use super::Bili; use fav_core::prelude::*; use reqwest::{header, header::HeaderMap}; use std::collections::HashMap; diff --git a/fav_utils/src/bili/data.rs b/fav_utils/src/bili/data.rs new file mode 100644 index 0000000..135ff6e --- /dev/null +++ b/fav_utils/src/bili/data.rs @@ -0,0 +1,19 @@ +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `bili.proto` + +include!(concat!(env!("OUT_DIR"), "/proto/bili.rs")); diff --git a/fav_utils/src/bili/local.rs b/fav_utils/src/bili/local.rs index da9c75c..666eebb 100644 --- a/fav_utils/src/bili/local.rs +++ b/fav_utils/src/bili/local.rs @@ -1,8 +1,5 @@ -use crate::{ - proto::bili::{Bili, BiliSets}, - utils::bar::download_bar, - FavUtilsError, -}; +use super::{Bili, BiliSets}; +use crate::{utils::bar::download_bar, FavUtilsError}; use fav_core::prelude::*; use reqwest::header::CONTENT_LENGTH; use std::io::{BufWriter, Write as _}; diff --git a/fav_utils/src/bili/mod.rs b/fav_utils/src/bili/mod.rs index d495c82..cad7d60 100644 --- a/fav_utils/src/bili/mod.rs +++ b/fav_utils/src/bili/mod.rs @@ -6,7 +6,9 @@ mod local; mod ops; mod res; -pub use crate::proto::bili::*; +pub mod data; + +pub use data::*; impl From for String { fn from(qn: Qn) -> Self { diff --git a/fav_utils/src/bili/ops.rs b/fav_utils/src/bili/ops.rs index f3d5cdb..0588e33 100644 --- a/fav_utils/src/bili/ops.rs +++ b/fav_utils/src/bili/ops.rs @@ -1,9 +1,6 @@ use super::api::ApiKind; -use crate::{ - proto::bili::{Bili, BiliRes, BiliSet, BiliSets}, - utils::qr::show_qr_code, - FavUtilsError, FavUtilsResult, -}; +use super::{Bili, BiliRes, BiliSet, BiliSets}; +use crate::{utils::qr::show_qr_code, FavUtilsError, FavUtilsResult}; use fav_core::{prelude::*, status::SetStatusExt as _}; use reqwest::Response; use std::collections::HashMap; @@ -173,8 +170,8 @@ fn try_extract_cookie(resp: &Response) -> FavUtilsResult #[cfg(test)] mod tests { + use super::BiliSets; use super::*; - use crate::proto::bili::BiliSets; use fav_core::ops::ResOpsExt; #[test] diff --git a/fav_utils/src/bili/res.rs b/fav_utils/src/bili/res.rs index a4150bb..bc49beb 100644 --- a/fav_utils/src/bili/res.rs +++ b/fav_utils/src/bili/res.rs @@ -1,4 +1,4 @@ -use crate::proto::bili::{BiliRes, BiliSet, BiliSets}; +use super::{BiliRes, BiliSet, BiliSets}; use fav_core::prelude::*; use std::ops::BitOrAssign; @@ -11,7 +11,7 @@ impl BitOrAssign for BiliSets { Some(s1) => { s1.media_count = s.media_count; *s1 |= s - }, + } None => cache.push(s), }); self.list.extend(cache); diff --git a/fav_utils/src/lib.rs b/fav_utils/src/lib.rs index b9d2ce6..26d43c2 100644 --- a/fav_utils/src/lib.rs +++ b/fav_utils/src/lib.rs @@ -2,8 +2,6 @@ #![deny(missing_docs, rustdoc::broken_intra_doc_links)] #![cfg_attr(all(doc, CHANNEL_NIGHTLY), feature(doc_auto_cfg))] -mod proto; - #[cfg(feature = "bili")] pub mod bili; #[cfg(feature = "bili")] diff --git a/fav_utils/src/proto/bili.rs b/fav_utils/src/proto/bili.rs deleted file mode 100644 index 3d37a8d..0000000 --- a/fav_utils/src/proto/bili.rs +++ /dev/null @@ -1,1231 +0,0 @@ -// This file is generated by rust-protobuf 3.3.0. Do not edit -// .proto file is parsed by pure -// @generated - -// https://github.com/rust-lang/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![allow(unused_attributes)] -#![cfg_attr(rustfmt, rustfmt::skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unused_results)] -#![allow(unused_mut)] - -//! Generated file from `bili.proto` - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_3_0; - -// @@protoc_insertion_point(message:bili.Bili) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct Bili { - // message fields - // @@protoc_insertion_point(field:bili.Bili.cookies) - pub cookies: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - // special fields - // @@protoc_insertion_point(special_field:bili.Bili.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a Bili { - fn default() -> &'a Bili { - ::default_instance() - } -} - -impl Bili { - pub fn new() -> Bili { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(1); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_map_simpler_accessor::<_, _, _>( - "cookies", - |m: &Bili| { &m.cookies }, - |m: &mut Bili| { &mut m.cookies }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "Bili", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for Bili { - const NAME: &'static str = "Bili"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => { - let len = is.read_raw_varint32()?; - let old_limit = is.push_limit(len as u64)?; - let mut key = ::std::default::Default::default(); - let mut value = ::std::default::Default::default(); - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => key = is.read_string()?, - 18 => value = is.read_string()?, - _ => ::protobuf::rt::skip_field_for_tag(tag, is)?, - }; - } - is.pop_limit(old_limit); - self.cookies.insert(key, value); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - for (k, v) in &self.cookies { - let mut entry_size = 0; - entry_size += ::protobuf::rt::string_size(1, &k); - entry_size += ::protobuf::rt::string_size(2, &v); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(entry_size) + entry_size - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - for (k, v) in &self.cookies { - let mut entry_size = 0; - entry_size += ::protobuf::rt::string_size(1, &k); - entry_size += ::protobuf::rt::string_size(2, &v); - os.write_raw_varint32(10)?; // Tag. - os.write_raw_varint32(entry_size as u32)?; - os.write_string(1, &k)?; - os.write_string(2, &v)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> Bili { - Bili::new() - } - - fn clear(&mut self) { - self.cookies.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static Bili { - static instance: ::protobuf::rt::Lazy = ::protobuf::rt::Lazy::new(); - instance.get(Bili::new) - } -} - -impl ::protobuf::MessageFull for Bili { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("Bili").unwrap()).clone() - } -} - -impl ::std::fmt::Display for Bili { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Bili { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -#[derive(fav_core::attr::Attr, fav_core::status::Status)] -#[attr(id(bvid))] -// @@protoc_insertion_point(message:bili.BiliRes) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct BiliRes { - // message fields - // @@protoc_insertion_point(field:bili.BiliRes.bvid) - pub bvid: ::std::string::String, - // @@protoc_insertion_point(field:bili.BiliRes.title) - pub title: ::std::string::String, - // @@protoc_insertion_point(field:bili.BiliRes.status) - pub status: i32, - // @@protoc_insertion_point(field:bili.BiliRes.cid) - pub cid: i64, - // @@protoc_insertion_point(field:bili.BiliRes.owner) - pub owner: ::protobuf::MessageField, - // @@protoc_insertion_point(field:bili.BiliRes.qn) - pub qn: ::protobuf::EnumOrUnknown, - // @@protoc_insertion_point(field:bili.BiliRes.pages) - pub pages: ::std::vec::Vec, - // special fields - // @@protoc_insertion_point(special_field:bili.BiliRes.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a BiliRes { - fn default() -> &'a BiliRes { - ::default_instance() - } -} - -impl BiliRes { - pub fn new() -> BiliRes { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(7); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "bvid", - |m: &BiliRes| { &m.bvid }, - |m: &mut BiliRes| { &mut m.bvid }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &BiliRes| { &m.title }, - |m: &mut BiliRes| { &mut m.title }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "status", - |m: &BiliRes| { &m.status }, - |m: &mut BiliRes| { &mut m.status }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "cid", - |m: &BiliRes| { &m.cid }, - |m: &mut BiliRes| { &mut m.cid }, - )); - fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Upper>( - "owner", - |m: &BiliRes| { &m.owner }, - |m: &mut BiliRes| { &mut m.owner }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "qn", - |m: &BiliRes| { &m.qn }, - |m: &mut BiliRes| { &mut m.qn }, - )); - fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( - "pages", - |m: &BiliRes| { &m.pages }, - |m: &mut BiliRes| { &mut m.pages }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "BiliRes", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for BiliRes { - const NAME: &'static str = "BiliRes"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 10 => { - self.bvid = is.read_string()?; - }, - 18 => { - self.title = is.read_string()?; - }, - 24 => { - self.status = is.read_int32()?; - }, - 32 => { - self.cid = is.read_int64()?; - }, - 42 => { - ::protobuf::rt::read_singular_message_into_field(is, &mut self.owner)?; - }, - 48 => { - self.qn = is.read_enum_or_unknown()?; - }, - 122 => { - self.pages.push(is.read_message()?); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if !self.bvid.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.bvid); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - if self.status != 0 { - my_size += ::protobuf::rt::int32_size(3, self.status); - } - if self.cid != 0 { - my_size += ::protobuf::rt::int64_size(4, self.cid); - } - if let Some(v) = self.owner.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - } - if self.qn != ::protobuf::EnumOrUnknown::new(Qn::Default) { - my_size += ::protobuf::rt::int32_size(6, self.qn.value()); - } - for value in &self.pages { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if !self.bvid.is_empty() { - os.write_string(1, &self.bvid)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - if self.status != 0 { - os.write_int32(3, self.status)?; - } - if self.cid != 0 { - os.write_int64(4, self.cid)?; - } - if let Some(v) = self.owner.as_ref() { - ::protobuf::rt::write_message_field_with_cached_size(5, v, os)?; - } - if self.qn != ::protobuf::EnumOrUnknown::new(Qn::Default) { - os.write_enum(6, ::protobuf::EnumOrUnknown::value(&self.qn))?; - } - for v in &self.pages { - ::protobuf::rt::write_message_field_with_cached_size(15, v, os)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> BiliRes { - BiliRes::new() - } - - fn clear(&mut self) { - self.bvid.clear(); - self.title.clear(); - self.status = 0; - self.cid = 0; - self.owner.clear(); - self.qn = ::protobuf::EnumOrUnknown::new(Qn::Default); - self.pages.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static BiliRes { - static instance: BiliRes = BiliRes { - bvid: ::std::string::String::new(), - title: ::std::string::String::new(), - status: 0, - cid: 0, - owner: ::protobuf::MessageField::none(), - qn: ::protobuf::EnumOrUnknown::from_i32(0), - pages: ::std::vec::Vec::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for BiliRes { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("BiliRes").unwrap()).clone() - } -} - -impl ::std::fmt::Display for BiliRes { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for BiliRes { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:bili.BiliPage) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct BiliPage { - // message fields - // @@protoc_insertion_point(field:bili.BiliPage.cid) - pub cid: i64, - // @@protoc_insertion_point(field:bili.BiliPage.page) - pub page: i32, - // @@protoc_insertion_point(field:bili.BiliPage.part) - pub part: ::std::string::String, - // special fields - // @@protoc_insertion_point(special_field:bili.BiliPage.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a BiliPage { - fn default() -> &'a BiliPage { - ::default_instance() - } -} - -impl BiliPage { - pub fn new() -> BiliPage { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(3); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "cid", - |m: &BiliPage| { &m.cid }, - |m: &mut BiliPage| { &mut m.cid }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "page", - |m: &BiliPage| { &m.page }, - |m: &mut BiliPage| { &mut m.page }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "part", - |m: &BiliPage| { &m.part }, - |m: &mut BiliPage| { &mut m.part }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "BiliPage", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for BiliPage { - const NAME: &'static str = "BiliPage"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.cid = is.read_int64()?; - }, - 16 => { - self.page = is.read_int32()?; - }, - 26 => { - self.part = is.read_string()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.cid != 0 { - my_size += ::protobuf::rt::int64_size(1, self.cid); - } - if self.page != 0 { - my_size += ::protobuf::rt::int32_size(2, self.page); - } - if !self.part.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.part); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.cid != 0 { - os.write_int64(1, self.cid)?; - } - if self.page != 0 { - os.write_int32(2, self.page)?; - } - if !self.part.is_empty() { - os.write_string(3, &self.part)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> BiliPage { - BiliPage::new() - } - - fn clear(&mut self) { - self.cid = 0; - self.page = 0; - self.part.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static BiliPage { - static instance: BiliPage = BiliPage { - cid: 0, - page: 0, - part: ::std::string::String::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for BiliPage { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("BiliPage").unwrap()).clone() - } -} - -impl ::std::fmt::Display for BiliPage { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for BiliPage { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -#[derive(fav_core::attr::Attr)] -#[attr(id(mid), title(name))] -// @@protoc_insertion_point(message:bili.Upper) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct Upper { - // message fields - // @@protoc_insertion_point(field:bili.Upper.mid) - pub mid: i64, - // @@protoc_insertion_point(field:bili.Upper.name) - pub name: ::std::string::String, - // special fields - // @@protoc_insertion_point(special_field:bili.Upper.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a Upper { - fn default() -> &'a Upper { - ::default_instance() - } -} - -impl Upper { - pub fn new() -> Upper { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(2); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "mid", - |m: &Upper| { &m.mid }, - |m: &mut Upper| { &mut m.mid }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "name", - |m: &Upper| { &m.name }, - |m: &mut Upper| { &mut m.name }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "Upper", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for Upper { - const NAME: &'static str = "Upper"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.mid = is.read_int64()?; - }, - 18 => { - self.name = is.read_string()?; - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.mid != 0 { - my_size += ::protobuf::rt::int64_size(1, self.mid); - } - if !self.name.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.name); - } - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.mid != 0 { - os.write_int64(1, self.mid)?; - } - if !self.name.is_empty() { - os.write_string(2, &self.name)?; - } - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> Upper { - Upper::new() - } - - fn clear(&mut self) { - self.mid = 0; - self.name.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static Upper { - static instance: Upper = Upper { - mid: 0, - name: ::std::string::String::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for Upper { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("Upper").unwrap()).clone() - } -} - -impl ::std::fmt::Display for Upper { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Upper { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -#[derive(fav_core::attr::Attr, fav_core::status::Status)] -// @@protoc_insertion_point(message:bili.BiliSet) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct BiliSet { - // message fields - // @@protoc_insertion_point(field:bili.BiliSet.id) - pub id: i64, - // @@protoc_insertion_point(field:bili.BiliSet.title) - pub title: ::std::string::String, - // @@protoc_insertion_point(field:bili.BiliSet.status) - pub status: i32, - // @@protoc_insertion_point(field:bili.BiliSet.media_count) - pub media_count: i32, - // @@protoc_insertion_point(field:bili.BiliSet.upper) - pub upper: ::protobuf::MessageField, - // @@protoc_insertion_point(field:bili.BiliSet.medias) - pub medias: ::std::vec::Vec, - // special fields - // @@protoc_insertion_point(special_field:bili.BiliSet.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a BiliSet { - fn default() -> &'a BiliSet { - ::default_instance() - } -} - -impl BiliSet { - pub fn new() -> BiliSet { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(6); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "id", - |m: &BiliSet| { &m.id }, - |m: &mut BiliSet| { &mut m.id }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "title", - |m: &BiliSet| { &m.title }, - |m: &mut BiliSet| { &mut m.title }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "status", - |m: &BiliSet| { &m.status }, - |m: &mut BiliSet| { &mut m.status }, - )); - fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( - "media_count", - |m: &BiliSet| { &m.media_count }, - |m: &mut BiliSet| { &mut m.media_count }, - )); - fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Upper>( - "upper", - |m: &BiliSet| { &m.upper }, - |m: &mut BiliSet| { &mut m.upper }, - )); - fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( - "medias", - |m: &BiliSet| { &m.medias }, - |m: &mut BiliSet| { &mut m.medias }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "BiliSet", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for BiliSet { - const NAME: &'static str = "BiliSet"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 8 => { - self.id = is.read_int64()?; - }, - 18 => { - self.title = is.read_string()?; - }, - 24 => { - self.status = is.read_int32()?; - }, - 32 => { - self.media_count = is.read_int32()?; - }, - 114 => { - ::protobuf::rt::read_singular_message_into_field(is, &mut self.upper)?; - }, - 122 => { - self.medias.push(is.read_message()?); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - if self.id != 0 { - my_size += ::protobuf::rt::int64_size(1, self.id); - } - if !self.title.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.title); - } - if self.status != 0 { - my_size += ::protobuf::rt::int32_size(3, self.status); - } - if self.media_count != 0 { - my_size += ::protobuf::rt::int32_size(4, self.media_count); - } - if let Some(v) = self.upper.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - } - for value in &self.medias { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - if self.id != 0 { - os.write_int64(1, self.id)?; - } - if !self.title.is_empty() { - os.write_string(2, &self.title)?; - } - if self.status != 0 { - os.write_int32(3, self.status)?; - } - if self.media_count != 0 { - os.write_int32(4, self.media_count)?; - } - if let Some(v) = self.upper.as_ref() { - ::protobuf::rt::write_message_field_with_cached_size(14, v, os)?; - } - for v in &self.medias { - ::protobuf::rt::write_message_field_with_cached_size(15, v, os)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> BiliSet { - BiliSet::new() - } - - fn clear(&mut self) { - self.id = 0; - self.title.clear(); - self.status = 0; - self.media_count = 0; - self.upper.clear(); - self.medias.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static BiliSet { - static instance: BiliSet = BiliSet { - id: 0, - title: ::std::string::String::new(), - status: 0, - media_count: 0, - upper: ::protobuf::MessageField::none(), - medias: ::std::vec::Vec::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for BiliSet { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("BiliSet").unwrap()).clone() - } -} - -impl ::std::fmt::Display for BiliSet { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for BiliSet { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -// @@protoc_insertion_point(message:bili.BiliSets) -#[derive(PartialEq,Clone,Default,Debug)] -pub struct BiliSets { - // message fields - // @@protoc_insertion_point(field:bili.BiliSets.list) - pub list: ::std::vec::Vec, - // special fields - // @@protoc_insertion_point(special_field:bili.BiliSets.special_fields) - pub special_fields: ::protobuf::SpecialFields, -} - -impl<'a> ::std::default::Default for &'a BiliSets { - fn default() -> &'a BiliSets { - ::default_instance() - } -} - -impl BiliSets { - pub fn new() -> BiliSets { - ::std::default::Default::default() - } - - fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(1); - let mut oneofs = ::std::vec::Vec::with_capacity(0); - fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( - "list", - |m: &BiliSets| { &m.list }, - |m: &mut BiliSets| { &mut m.list }, - )); - ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( - "BiliSets", - fields, - oneofs, - ) - } -} - -impl ::protobuf::Message for BiliSets { - const NAME: &'static str = "BiliSets"; - - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { - while let Some(tag) = is.read_raw_tag_or_eof()? { - match tag { - 122 => { - self.list.push(is.read_message()?); - }, - tag => { - ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u64 { - let mut my_size = 0; - for value in &self.list { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); - self.special_fields.cached_size().set(my_size as u32); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { - for v in &self.list { - ::protobuf::rt::write_message_field_with_cached_size(15, v, os)?; - }; - os.write_unknown_fields(self.special_fields.unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn special_fields(&self) -> &::protobuf::SpecialFields { - &self.special_fields - } - - fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { - &mut self.special_fields - } - - fn new() -> BiliSets { - BiliSets::new() - } - - fn clear(&mut self) { - self.list.clear(); - self.special_fields.clear(); - } - - fn default_instance() -> &'static BiliSets { - static instance: BiliSets = BiliSets { - list: ::std::vec::Vec::new(), - special_fields: ::protobuf::SpecialFields::new(), - }; - &instance - } -} - -impl ::protobuf::MessageFull for BiliSets { - fn descriptor() -> ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().message_by_package_relative_name("BiliSets").unwrap()).clone() - } -} - -impl ::std::fmt::Display for BiliSets { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for BiliSets { - type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; -} - -#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] -// @@protoc_insertion_point(enum:bili.Qn) -pub enum Qn { - // @@protoc_insertion_point(enum_value:bili.Qn.Default) - Default = 0, - // @@protoc_insertion_point(enum_value:bili.Qn.EightK) - EightK = 127, - // @@protoc_insertion_point(enum_value:bili.Qn.Dolby) - Dolby = 126, - // @@protoc_insertion_point(enum_value:bili.Qn.HDR) - HDR = 125, - // @@protoc_insertion_point(enum_value:bili.Qn.FourK) - FourK = 120, - // @@protoc_insertion_point(enum_value:bili.Qn.FullHDHighFrame) - FullHDHighFrame = 116, - // @@protoc_insertion_point(enum_value:bili.Qn.FullHDHighCode) - FullHDHighCode = 112, - // @@protoc_insertion_point(enum_value:bili.Qn.FullHD) - FullHD = 80, - // @@protoc_insertion_point(enum_value:bili.Qn.HDHighFrame) - HDHighFrame = 74, - // @@protoc_insertion_point(enum_value:bili.Qn.HD) - HD = 64, - // @@protoc_insertion_point(enum_value:bili.Qn.SD) - SD = 32, - // @@protoc_insertion_point(enum_value:bili.Qn.LD) - LD = 16, - // @@protoc_insertion_point(enum_value:bili.Qn.VLD) - VLD = 6, -} - -impl ::protobuf::Enum for Qn { - const NAME: &'static str = "Qn"; - - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(Qn::Default), - 127 => ::std::option::Option::Some(Qn::EightK), - 126 => ::std::option::Option::Some(Qn::Dolby), - 125 => ::std::option::Option::Some(Qn::HDR), - 120 => ::std::option::Option::Some(Qn::FourK), - 116 => ::std::option::Option::Some(Qn::FullHDHighFrame), - 112 => ::std::option::Option::Some(Qn::FullHDHighCode), - 80 => ::std::option::Option::Some(Qn::FullHD), - 74 => ::std::option::Option::Some(Qn::HDHighFrame), - 64 => ::std::option::Option::Some(Qn::HD), - 32 => ::std::option::Option::Some(Qn::SD), - 16 => ::std::option::Option::Some(Qn::LD), - 6 => ::std::option::Option::Some(Qn::VLD), - _ => ::std::option::Option::None - } - } - - fn from_str(str: &str) -> ::std::option::Option { - match str { - "Default" => ::std::option::Option::Some(Qn::Default), - "EightK" => ::std::option::Option::Some(Qn::EightK), - "Dolby" => ::std::option::Option::Some(Qn::Dolby), - "HDR" => ::std::option::Option::Some(Qn::HDR), - "FourK" => ::std::option::Option::Some(Qn::FourK), - "FullHDHighFrame" => ::std::option::Option::Some(Qn::FullHDHighFrame), - "FullHDHighCode" => ::std::option::Option::Some(Qn::FullHDHighCode), - "FullHD" => ::std::option::Option::Some(Qn::FullHD), - "HDHighFrame" => ::std::option::Option::Some(Qn::HDHighFrame), - "HD" => ::std::option::Option::Some(Qn::HD), - "SD" => ::std::option::Option::Some(Qn::SD), - "LD" => ::std::option::Option::Some(Qn::LD), - "VLD" => ::std::option::Option::Some(Qn::VLD), - _ => ::std::option::Option::None - } - } - - const VALUES: &'static [Qn] = &[ - Qn::Default, - Qn::EightK, - Qn::Dolby, - Qn::HDR, - Qn::FourK, - Qn::FullHDHighFrame, - Qn::FullHDHighCode, - Qn::FullHD, - Qn::HDHighFrame, - Qn::HD, - Qn::SD, - Qn::LD, - Qn::VLD, - ]; -} - -impl ::protobuf::EnumFull for Qn { - fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { - static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); - descriptor.get(|| file_descriptor().enum_by_package_relative_name("Qn").unwrap()).clone() - } - - fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { - let index = match self { - Qn::Default => 0, - Qn::EightK => 1, - Qn::Dolby => 2, - Qn::HDR => 3, - Qn::FourK => 4, - Qn::FullHDHighFrame => 5, - Qn::FullHDHighCode => 6, - Qn::FullHD => 7, - Qn::HDHighFrame => 8, - Qn::HD => 9, - Qn::SD => 10, - Qn::LD => 11, - Qn::VLD => 12, - }; - Self::enum_descriptor().value_by_index(index) - } -} - -impl ::std::default::Default for Qn { - fn default() -> Self { - Qn::Default - } -} - -impl Qn { - fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { - ::protobuf::reflect::GeneratedEnumDescriptorData::new::("Qn") - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\nbili.proto\x12\x04bili\"u\n\x04Bili\x121\n\x07cookies\x18\x01\x20\ - \x03(\x0b2\x17.bili.Bili.CookiesEntryR\x07cookies\x1a:\n\x0cCookiesEntry\ - \x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\ - \x20\x01(\tR\x05value:\x028\x01\"\xc0\x01\n\x07BiliRes\x12\x12\n\x04bvid\ - \x18\x01\x20\x01(\tR\x04bvid\x12\x14\n\x05title\x18\x02\x20\x01(\tR\x05t\ - itle\x12\x16\n\x06status\x18\x03\x20\x01(\x05R\x06status\x12\x10\n\x03ci\ - d\x18\x04\x20\x01(\x03R\x03cid\x12!\n\x05owner\x18\x05\x20\x01(\x0b2\x0b\ - .bili.UpperR\x05owner\x12\x18\n\x02qn\x18\x06\x20\x01(\x0e2\x08.bili.QnR\ - \x02qn\x12$\n\x05pages\x18\x0f\x20\x03(\x0b2\x0e.bili.BiliPageR\x05pages\ - \"D\n\x08BiliPage\x12\x10\n\x03cid\x18\x01\x20\x01(\x03R\x03cid\x12\x12\ - \n\x04page\x18\x02\x20\x01(\x05R\x04page\x12\x12\n\x04part\x18\x03\x20\ - \x01(\tR\x04part\"-\n\x05Upper\x12\x10\n\x03mid\x18\x01\x20\x01(\x03R\ - \x03mid\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\"\xb2\x01\n\x07Bil\ - iSet\x12\x0e\n\x02id\x18\x01\x20\x01(\x03R\x02id\x12\x14\n\x05title\x18\ - \x02\x20\x01(\tR\x05title\x12\x16\n\x06status\x18\x03\x20\x01(\x05R\x06s\ - tatus\x12\x1f\n\x0bmedia_count\x18\x04\x20\x01(\x05R\nmediaCount\x12!\n\ - \x05upper\x18\x0e\x20\x01(\x0b2\x0b.bili.UpperR\x05upper\x12%\n\x06media\ - s\x18\x0f\x20\x03(\x0b2\r.bili.BiliResR\x06medias\"-\n\x08BiliSets\x12!\ - \n\x04list\x18\x0f\x20\x03(\x0b2\r.bili.BiliSetR\x04list*\xa3\x01\n\x02Q\ - n\x12\x0b\n\x07Default\x10\0\x12\n\n\x06EightK\x10\x7f\x12\t\n\x05Dolby\ - \x10~\x12\x07\n\x03HDR\x10}\x12\t\n\x05FourK\x10x\x12\x13\n\x0fFullHDHig\ - hFrame\x10t\x12\x12\n\x0eFullHDHighCode\x10p\x12\n\n\x06FullHD\x10P\x12\ - \x0f\n\x0bHDHighFrame\x10J\x12\x06\n\x02HD\x10@\x12\x06\n\x02SD\x10\x20\ - \x12\x06\n\x02LD\x10\x10\x12\x07\n\x03VLD\x10\x06b\x06proto3\ -"; - -/// `FileDescriptorProto` object which was a source for this generated file -fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); - file_descriptor_proto_lazy.get(|| { - ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() - }) -} - -/// `FileDescriptor` object which allows dynamic access to files -pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { - static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); - static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); - file_descriptor.get(|| { - let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { - let mut deps = ::std::vec::Vec::with_capacity(0); - let mut messages = ::std::vec::Vec::with_capacity(6); - messages.push(Bili::generated_message_descriptor_data()); - messages.push(BiliRes::generated_message_descriptor_data()); - messages.push(BiliPage::generated_message_descriptor_data()); - messages.push(Upper::generated_message_descriptor_data()); - messages.push(BiliSet::generated_message_descriptor_data()); - messages.push(BiliSets::generated_message_descriptor_data()); - let mut enums = ::std::vec::Vec::with_capacity(1); - enums.push(Qn::generated_enum_descriptor_data()); - ::protobuf::reflect::GeneratedFileDescriptor::new_generated( - file_descriptor_proto(), - deps, - messages, - enums, - ) - }); - ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) - }) -} diff --git a/fav_utils/src/proto/mod.rs b/fav_utils/src/proto/mod.rs deleted file mode 100644 index eea5237..0000000 --- a/fav_utils/src/proto/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -// @generated - -pub mod bili;