add async feature #1

Merged
b4tman merged 62 commits from async into master 2023-08-18 06:29:46 +00:00
Showing only changes of commit 21571787f2 - Show all commits

View File

@ -1,8 +1,9 @@
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Serialize, Deserialize)] #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct SourceQuestion { pub struct SourceQuestion {
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "u32_is_zero")]
pub num: u32, pub num: u32,
pub id: String, pub id: String,
@ -13,96 +14,125 @@ pub struct SourceQuestion {
#[serde(alias = "Автор")] #[serde(alias = "Автор")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub author: String, pub author: String,
#[serde(alias = "Комментарий")] #[serde(alias = "Комментарий")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub comment: String, pub comment: String,
#[serde(alias = "Комментарии")] #[serde(alias = "Комментарии")]
#[serde(alias = "Инфо")] #[serde(alias = "Инфо")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub comment1: String, pub comment1: String,
#[serde(alias = "Тур")] #[serde(alias = "Тур")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub tour: String, pub tour: String,
#[serde(alias = "Ссылка")] #[serde(alias = "Ссылка")]
#[serde(alias = "URL")] #[serde(alias = "URL")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub url: String, pub url: String,
#[serde(alias = "Дата")] #[serde(alias = "Дата")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub date: String, pub date: String,
#[serde(alias = "Обработан")] #[serde(alias = "Обработан")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub processed_by: String, pub processed_by: String,
#[serde(alias = "Редактор")] #[serde(alias = "Редактор")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub redacted_by: String, pub redacted_by: String,
#[serde(alias = "Копирайт")] #[serde(alias = "Копирайт")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub copyright: String, pub copyright: String,
#[serde(alias = "Тема")] #[serde(alias = "Тема")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub theme: String, pub theme: String,
#[serde(alias = "Вид")] #[serde(alias = "Вид")]
#[serde(alias = "Тип")] #[serde(alias = "Тип")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub kind: String, pub kind: String,
#[serde(alias = "Источник")] #[serde(alias = "Источник")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub source: String, pub source: String,
#[serde(alias = "Рейтинг")] #[serde(alias = "Рейтинг")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub rating: String, pub rating: String,
} }
#[derive(Debug, Default, Clone, Serialize, Deserialize)] #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct SourceQuestionsBatch { pub struct SourceQuestionsBatch {
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub filename: String, pub filename: String,
#[serde(alias = "Пакет")] #[serde(alias = "Пакет")]
#[serde(alias = "Чемпионат")] #[serde(alias = "Чемпионат")]
pub description: String, pub description: String,
#[serde(alias = "Автор")] #[serde(alias = "Автор")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub author: String, pub author: String,
#[serde(alias = "Комментарий")] #[serde(alias = "Комментарий")]
#[serde(alias = "Комментарии")] #[serde(alias = "Комментарии")]
#[serde(alias = "Инфо")] #[serde(alias = "Инфо")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub comment: String, pub comment: String,
#[serde(alias = "Ссылка")] #[serde(alias = "Ссылка")]
#[serde(alias = "URL")] #[serde(alias = "URL")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub url: String, pub url: String,
#[serde(alias = "Дата")] #[serde(alias = "Дата")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub date: String, pub date: String,
#[serde(alias = "Обработан")] #[serde(alias = "Обработан")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub processed_by: String, pub processed_by: String,
#[serde(alias = "Редактор")] #[serde(alias = "Редактор")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub redacted_by: String, pub redacted_by: String,
#[serde(alias = "Копирайт")] #[serde(alias = "Копирайт")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub copyright: String, pub copyright: String,
#[serde(alias = "Тема")] #[serde(alias = "Тема")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub theme: String, pub theme: String,
#[serde(alias = "Вид")] #[serde(alias = "Вид")]
#[serde(alias = "Тип")] #[serde(alias = "Тип")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub kind: String, pub kind: String,
#[serde(alias = "Источник")] #[serde(alias = "Источник")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub source: String, pub source: String,
#[serde(alias = "Рейтинг")] #[serde(alias = "Рейтинг")]
#[serde(default)] #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]
pub rating: String, pub rating: String,
#[serde(alias = "Вопросы")] #[serde(alias = "Вопросы")]
pub questions: Vec<SourceQuestion>, pub questions: Vec<SourceQuestion>,
} }
fn u32_is_zero(num: &u32) -> bool {
*num == 0
}
#[cfg(any(feature = "convert", feature = "source"))] #[cfg(any(feature = "convert", feature = "source"))]
pub mod reader_sync { pub mod reader_sync {
use std::io::{Read, Seek}; use std::io::{Read, Seek};