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

View File

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

View File

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

View File

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