Remove versioning from data type enum members

This commit is contained in:
jeff 2021-01-01 22:56:41 +00:00
parent 2cb547e16a
commit 14863353f0
4 changed files with 12 additions and 12 deletions

View File

@ -51,8 +51,8 @@ pub(crate) trait Visibility {
#[derive(Debug, Serialize, PartialEq, Clone, Copy, EnumIter, EnumString, sqlx::Type)] #[derive(Debug, Serialize, PartialEq, Clone, Copy, EnumIter, EnumString, sqlx::Type)]
#[sqlx(rename_all = "snake_case")] #[sqlx(rename_all = "snake_case")]
pub enum CharacterDataType { pub enum CharacterDataType {
ChroniclesOfDarknessV1, ChroniclesOfDarkness,
ChangelingV1, Changeling,
} }
impl CharacterDataType { impl CharacterDataType {
@ -62,13 +62,13 @@ impl CharacterDataType {
use prost::Message; use prost::Message;
use CharacterDataType::*; use CharacterDataType::*;
let data: BytesMut = match self { let data: BytesMut = match self {
ChroniclesOfDarknessV1 => { ChroniclesOfDarkness => {
let sheet = CofdSheet::default_sheet(); let sheet = CofdSheet::default_sheet();
let mut buf = BytesMut::with_capacity(std::mem::size_of_val(&sheet)); let mut buf = BytesMut::with_capacity(std::mem::size_of_val(&sheet));
sheet.encode(&mut buf)?; sheet.encode(&mut buf)?;
buf buf
} }
ChangelingV1 => { Changeling => {
let sheet = ChangelingSheet::default_sheet(); let sheet = ChangelingSheet::default_sheet();
let mut buf = BytesMut::with_capacity(std::mem::size_of_val(&sheet)); let mut buf = BytesMut::with_capacity(std::mem::size_of_val(&sheet));
sheet.encode(&mut buf)?; sheet.encode(&mut buf)?;
@ -121,8 +121,8 @@ impl Character {
pub fn dyn_deserialize(&self) -> Result<Box<DynCharacterData>, Error> { pub fn dyn_deserialize(&self) -> Result<Box<DynCharacterData>, Error> {
use CharacterDataType::*; use CharacterDataType::*;
let decoded: Box<dyn erased_serde::Serialize> = match self.data_type { let decoded: Box<dyn erased_serde::Serialize> = match self.data_type {
ChroniclesOfDarknessV1 => Box::new(self.try_deserialize::<CofdSheet>()?), ChroniclesOfDarkness => Box::new(self.try_deserialize::<CofdSheet>()?),
ChangelingV1 => Box::new(self.try_deserialize::<ChangelingSheet>()?), Changeling => Box::new(self.try_deserialize::<ChangelingSheet>()?),
}; };
Ok(decoded) Ok(decoded)

View File

@ -39,8 +39,8 @@ fn view_character_template(user: &User, character: Character) -> Result<Template
use CharacterDataType::*; use CharacterDataType::*;
let template = match character.data_type { let template = match character.data_type {
ChroniclesOfDarknessV1 => Template::render("characters/view_character", context), ChroniclesOfDarkness => Template::render("characters/view_character", context),
ChangelingV1 => Template::render("characters/view_changeling_character", context), Changeling => Template::render("characters/view_changeling_character", context),
}; };
Ok(template) Ok(template)

View File

@ -35,8 +35,8 @@ fn edit_character_template(user: &User, character: Character) -> Result<Template
use CharacterDataType::*; use CharacterDataType::*;
let template = match character.data_type { let template = match character.data_type {
ChroniclesOfDarknessV1 => Template::render("characters/edit_character", context), ChroniclesOfDarkness => Template::render("characters/edit_character", context),
ChangelingV1 => Template::render("characters/edit_changeling_character", context), Changeling => Template::render("characters/edit_changeling_character", context),
}; };
Ok(template) Ok(template)

View File

@ -32,7 +32,7 @@ impl NewCharacterContext {
NewCharacterContext { NewCharacterContext {
name: "".to_string(), name: "".to_string(),
error_message: "".to_string(), error_message: "".to_string(),
selected_system: CharacterDataType::ChroniclesOfDarknessV1, selected_system: CharacterDataType::ChroniclesOfDarkness,
systems: CharacterDataType::iter().collect(), systems: CharacterDataType::iter().collect(),
} }
} }
@ -43,7 +43,7 @@ impl NewCharacterContext {
let system: CharacterDataType = *form let system: CharacterDataType = *form
.system .system
.as_ref() .as_ref()
.unwrap_or(&CharacterDataType::ChroniclesOfDarknessV1); .unwrap_or(&CharacterDataType::ChroniclesOfDarkness);
NewCharacterContext { NewCharacterContext {
name: form.name.clone(), name: form.name.clone(),