Add return Result<(),Errorfr> for everything just for the sake of future proofing

This commit is contained in:
endernon 2025-01-11 00:20:37 +00:00
parent 281ff67005
commit fb2a5e8c02

View file

@ -14,7 +14,7 @@ use idmangler_lib::{
use idmangler_lib::encoding::DataEncoder;
use std::collections::HashMap;
pub fn encode_startdata(general_params: &mut FuncParams) {
pub fn encode_startdata(general_params: &mut FuncParams) -> Result<(), Errorfr> {
if *general_params.fr_debug_mode {
println!("Encoding StartData")
}
@ -22,8 +22,9 @@ pub fn encode_startdata(general_params: &mut FuncParams) {
StartData(general_params.fr_ver)
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}
pub fn encode_typedata(general_params: &mut FuncParams, item_type_deser: ItemTypeDeser) {
pub fn encode_typedata(general_params: &mut FuncParams, item_type_deser: ItemTypeDeser) -> Result<(), Errorfr> {
if *general_params.fr_debug_mode {
println!("Encoding TypeData: {:?}", item_type_deser);
}
@ -31,11 +32,9 @@ pub fn encode_typedata(general_params: &mut FuncParams, item_type_deser: ItemTyp
TypeData(ItemType::from(item_type_deser))
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}
pub fn encode_typedata_custom(
general_params: &mut FuncParams,
crafted_type: &str,
) -> Result<(), Errorfr> {
pub fn encode_typedata_custom(general_params: &mut FuncParams, crafted_type: &str) -> Result<(), Errorfr> {
let frfr_type = CraftedTypesFr::try_from(crafted_type)?;
match frfr_type {
CraftedTypesFr::Gear(a) => {
@ -57,10 +56,7 @@ pub fn encode_typedata_custom(
}
Ok(())
}
pub fn encode_duradata(
general_params: &mut FuncParams,
real_dura: &Durability,
) -> Result<(), Errorfr> {
pub fn encode_duradata(general_params: &mut FuncParams, real_dura: &Durability) -> Result<(), Errorfr> {
let effect_strength_fr: u8; // but actually it should be 0 to 100, not 0 to 255. But i dunno how to use u7 data type.
if let Some(effstr) = real_dura.effect_strength {
if *general_params.fr_debug_mode {
@ -115,7 +111,7 @@ pub fn encode_duradata(
.unwrap();
Ok(())
}
pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: RequirementsDeser) {
pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: RequirementsDeser) -> Result<(), Errorfr> {
if *general_params.fr_debug_mode {
println!(
"Encoding RequirementData.Level: {:?}",
@ -145,9 +141,10 @@ pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: Requirement
skills: spvec,
}
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap()
.unwrap();
Ok(())
}
pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) -> Result<(), Errorfr> {
// ENCODE: NameData
if *general_params.fr_debug_mode {
println!("Encoding NameData: {:?}", &real_name)
@ -155,12 +152,9 @@ pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
NameData(real_name.trim().to_string())
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}
pub fn encode_iddata(
general_params: &mut FuncParams,
real_ids: &Vec<Identificationer>,
idsmap: HashMap<String, u8>,
) {
pub fn encode_iddata(general_params: &mut FuncParams, real_ids: &Vec<Identificationer>, idsmap: HashMap<String, u8>) -> Result<(), Errorfr> {
let mut idvec = Vec::new();
for eachid in real_ids {
let id_id = idsmap.get(eachid.id.trim());
@ -193,6 +187,7 @@ pub fn encode_iddata(
}
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}
pub fn encode_powderdata(general_params: &mut FuncParams, real_powders: &Vec<PowderFr>) -> Result<(), Errorfr> {
let mut powdervec = Vec::new();
@ -233,7 +228,7 @@ pub fn encode_powderdata(general_params: &mut FuncParams, real_powders: &Vec<Pow
.unwrap();
Ok(())
}
pub fn encode_rerolldata(general_params: &mut FuncParams, rerollcount: u8) {
pub fn encode_rerolldata(general_params: &mut FuncParams, rerollcount: u8) -> Result<(), Errorfr> {
if rerollcount != 0 {
// ENCODE: RerollData if applicable
RerollData(rerollcount)
@ -243,12 +238,9 @@ pub fn encode_rerolldata(general_params: &mut FuncParams, rerollcount: u8) {
dbg!(rerollcount);
}
}
Ok(())
}
pub fn encode_shinydata(
general_params: &mut FuncParams,
shiny: &Shinyjson,
json_shiny: &Vec<Shinystruct>,
) {
pub fn encode_shinydata(general_params: &mut FuncParams, shiny: &Shinyjson, json_shiny: &Vec<Shinystruct>) -> Result<(), Errorfr> {
let mut realshinykey: u8;
let _shinykey = &shiny.key;
let shinyvalue = shiny.value;
@ -272,8 +264,9 @@ pub fn encode_shinydata(
}
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}
pub fn encode_enddata(general_params: &mut FuncParams) {
pub fn encode_enddata(general_params: &mut FuncParams) -> Result<(), Errorfr> {
if *general_params.fr_debug_mode {
println!("Encoding EndData")
}
@ -281,4 +274,5 @@ pub fn encode_enddata(general_params: &mut FuncParams) {
EndData
.encode(general_params.fr_ver, general_params.fr_out)
.unwrap();
Ok(())
}