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 c061fef267 - Show all commits

View File

@ -1,74 +1,88 @@
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode, PartialEq,
)]
pub struct BatchInfo {
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub filename: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub description: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub author: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub comment: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub url: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub date: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub processed_by: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub redacted_by: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub copyright: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub theme: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub kind: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub source: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub rating: String,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode, PartialEq,
)]
pub struct Question {
#[serde(default)]
#[serde(default, skip_serializing_if = "u32_is_zero")]
pub num: u32,
pub id: String,
pub description: String,
pub answer: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub author: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub comment: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub comment1: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub tour: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub url: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub date: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub processed_by: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub redacted_by: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub copyright: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub theme: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub kind: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub source: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "String::is_empty")]
pub rating: String,
#[serde(default)]
#[serde(default, skip_serializing_if = "BatchInfo::is_default")]
pub batch_info: BatchInfo,
}
fn u32_is_zero(num: &u32) -> bool {
*num == 0
}
impl BatchInfo {
pub fn is_default(&self) -> bool {
*self == BatchInfo::default()
}
}
#[cfg(any(feature = "convert", feature = "convert_async"))]
pub mod convert_common {
use super::{BatchInfo, Question};