Skip to content

Commit

Permalink
style: Use cargo clippy on src-tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
false-spring committed Mar 11, 2024
1 parent f18f279 commit b06fde2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
let hook_lib_path = fs::canonicalize("../src-hook").unwrap();

Command::new("cargo")
.args(&["build", "--release"])
.args(["build", "--release"])
.current_dir(&hook_lib_path)
.status()
.expect("Could not build hook library.");
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rusqlite_migration::{Migrations, M};
pub fn setup_db() -> Result<()> {
let mut conn = Connection::open("logs.db")?;

conn.pragma_update(None, "journal_mode", &"WAL")?;
conn.pragma_update(None, "journal_mode", "WAL")?;

let migrations = Migrations::new(vec![
M::up(
Expand Down Expand Up @@ -38,7 +38,7 @@ pub fn setup_db() -> Result<()> {
/// Connect to database.
pub fn connect_to_db() -> Result<Connection> {
let conn = Connection::open("logs.db")?;
conn.pragma_update(None, "journal_mode", &"WAL")?;
conn.pragma_update(None, "journal_mode", "WAL")?;

Ok(conn)
}
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn export_damage_log_to_file(id: u32, options: ParseOptions) -> Result<(), Strin

let parser = parser::deserialize_version(&blob, version).map_err(|e| e.to_string())?;

let file = File::create(&file_path).map_err(|e| e.to_string())?;
let file = File::create(file_path).map_err(|e| e.to_string())?;

// @TODO(false): Split formatting into a separate function.
let mut writer = std::io::BufWriter::new(file);
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub mod v1;

pub fn deserialize_version(data: &[u8], version: u8) -> anyhow::Result<v1::Parser> {
match version {
0 => Ok(v0::Parser::from_blob(&data)?.into()),
1 => Ok(v1::Parser::from_encounter_blob(&data)?),
0 => Ok(v0::Parser::from_blob(data)?.into()),
1 => Ok(v1::Parser::from_encounter_blob(data)?),
_ => Err(anyhow::anyhow!("Unknown version")),
}
}
23 changes: 7 additions & 16 deletions src-tauri/src/parser/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl PlayerState {

// Otherwise, create a new skill and track it.
let mut skill = SkillState::new(
event.action_id.clone(),
event.action_id,
CharacterType::from_hash(event.source.actor_type),
);

Expand All @@ -172,22 +172,13 @@ impl EnemyState {
}

/// The necessary details of an encounter that can be used to recreate the state at any point in time.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Encounter {
player_data: [Option<PlayerData>; 4],
pub event_log: Vec<(i64, DamageEvent)>,
}

impl Default for Encounter {
fn default() -> Self {
Self {
player_data: [None, None, None, None],
event_log: vec![],
}
}
}

impl Encounter {
/// Compresses this encounter data into a binary blob.
pub fn to_blob(&self) -> Result<Vec<u8>> {
Expand Down Expand Up @@ -297,7 +288,7 @@ impl DerivedEncounterState {
});

// Update player stats from damage event.
source_player.update_from_damage_event(&event);
source_player.update_from_damage_event(event);

// Update target stats from damage event.
let target = self
Expand All @@ -310,7 +301,7 @@ impl DerivedEncounterState {
total_damage: 0,
});

target.update_from_damage_event(&event);
target.update_from_damage_event(event);

// Update everyone's DPS
for player in self.party.values_mut() {
Expand Down Expand Up @@ -378,12 +369,12 @@ impl Parser {
self.derived_state.start(self.start_time());

for (timestamp, event) in self.encounter.event_log.iter() {
self.derived_state.process_damage_event(*timestamp, &event);
self.derived_state.process_damage_event(*timestamp, event);
}
}

// Re-analyzes the encounter with the given targets.
pub fn reparse_with_options(&mut self, targets: &Vec<EnemyType>) {
pub fn reparse_with_options(&mut self, targets: &[EnemyType]) {
self.derived_state = Default::default();
self.derived_state.start(self.start_time());

Expand All @@ -393,7 +384,7 @@ impl Parser {
let target_type = EnemyType::from_hash(event.target.parent_actor_type);

if targets.is_empty() || targets.contains(&target_type) {
self.derived_state.process_damage_event(*timestamp, &event);
self.derived_state.process_damage_event(*timestamp, event);
}
}
}
Expand Down

0 comments on commit b06fde2

Please sign in to comment.