use rkyv::{
Archive, Deserialize, Serialize,
api::high::{HighDeserializer, HighSerializer},
rancor::Error as RkyvError,
ser::allocator::ArenaHandle,
util::AlignedVec,
};
pub trait RkyvDe<T>: Deserialize<T, HighDeserializer<RkyvError>> {}
pub trait RkyvSer:
for<'a> Serialize<HighSerializer<AlignedVec, ArenaHandle<'a>, RkyvError>>
{
}
pub trait Saveable {
fn base_name() -> &'static str;
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct MakeRow {
pub name: String,
pub country: String,
pub region: String,
}
impl RkyvSer for MakeRow {}
impl RkyvDe<MakeRow> for ArchivedMakeRow {}
impl Saveable for MakeRow {
fn base_name() -> &'static str {
"wmi_make"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct EuModelRow {
pub name: String,
pub first_year: u16,
pub last_year: u16,
}
impl RkyvSer for EuModelRow {}
impl RkyvDe<EuModelRow> for ArchivedEuModelRow {}
impl Saveable for EuModelRow {
fn base_name() -> &'static str {
"eu_brand_models"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct EngineRow {
pub model: String,
pub year: u16,
pub name: String,
pub cylinders: String,
pub displacement_cm3: u32,
pub power_kw: u32,
pub power_hp: u32,
pub torque_nm: u32,
pub fuel: String,
pub drive: String,
pub gearbox: String,
}
impl RkyvSer for EngineRow {}
impl RkyvDe<EngineRow> for ArchivedEngineRow {}
impl Saveable for EngineRow {
fn base_name() -> &'static str {
"eu_engines"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct SchemaRow {
pub id: String,
}
impl RkyvSer for SchemaRow {}
impl RkyvDe<SchemaRow> for ArchivedSchemaRow {}
impl Saveable for SchemaRow {
fn base_name() -> &'static str {
"wmi_schema"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct LookupRow {
pub pattern: String,
pub element: String,
pub value: String,
pub weight: u32,
}
impl RkyvSer for LookupRow {}
impl RkyvDe<LookupRow> for ArchivedLookupRow {}
impl Saveable for LookupRow {
fn base_name() -> &'static str {
"schema_lookup"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct ModelRow {
pub name: String,
}
impl RkyvSer for ModelRow {}
impl RkyvDe<ModelRow> for ArchivedModelRow {}
impl Saveable for ModelRow {
fn base_name() -> &'static str {
"make_models"
}
}
#[derive(Archive, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct VinRuleRow {
pub remainder: String,
pub make: String,
pub model: String,
}
impl RkyvSer for VinRuleRow {}
impl RkyvDe<VinRuleRow> for ArchivedVinRuleRow {}
impl Saveable for VinRuleRow {
fn base_name() -> &'static str {
"wmi_rules"
}
}