Skip to content

Commit cd9099c

Browse files
committed
Tweaked dcliah print args to reduce
cargo fmt
1 parent d612bbd commit cd9099c

File tree

11 files changed

+408
-174
lines changed

11 files changed

+408
-174
lines changed

src/dcli/src/activitystoreinterface.rs

Lines changed: 165 additions & 67 deletions
Large diffs are not rendered by default.

src/dcli/src/apiinterface.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
3131
use crate::enums::mode::Mode;
3232
use crate::enums::platform::Platform;
3333
use crate::error::Error;
34-
use crate::response::activities::{ActivitiesResponse, Activity, MAX_ACTIVITIES_REQUEST_COUNT};
34+
use crate::response::activities::{
35+
ActivitiesResponse, Activity, MAX_ACTIVITIES_REQUEST_COUNT,
36+
};
3537
use crate::response::drs::API_RESPONSE_STATUS_SUCCESS;
3638
use crate::response::gpr::{CharacterActivitiesData, GetProfileResponse};
3739
use crate::response::pgcr::{DestinyPostGameCarnageReportData, PGCRResponse};
3840
use crate::response::stats::{
39-
AllTimePvPStatsResponse, DailyPvPStatsResponse, DailyPvPStatsValuesData, PvpStatsData,
41+
AllTimePvPStatsResponse, DailyPvPStatsResponse, DailyPvPStatsValuesData,
42+
PvpStatsData,
4043
};
4144
use crate::utils::Period;
4245
use crate::{apiclient::ApiClient, crucible::Player};
@@ -138,7 +141,9 @@ impl ApiInterface {
138141
Some(e) => e,
139142
None => {
140143
return Err(Error::ApiRequest {
141-
description: String::from("No response data from API Call."),
144+
description: String::from(
145+
"No response data from API Call.",
146+
),
142147
})
143148
}
144149
};
@@ -338,7 +343,14 @@ impl ApiInterface {
338343
// so assume we are out of data. (maybe compare to whether we have found any items).
339344
// This would mean we might miss legitimate API errors though.
340345
let activities = self
341-
.retrieve_activities(member_id, character_id, platform, mode, count, page)
346+
.retrieve_activities(
347+
member_id,
348+
character_id,
349+
platform,
350+
mode,
351+
count,
352+
page,
353+
)
342354
.await?;
343355

344356
if activities.is_none() {
@@ -407,7 +419,14 @@ impl ApiInterface {
407419
// so assume we are out of data. (maybe compare to whether we have found any items).
408420
// This would mean we might miss legitimate API errors though.
409421
let activities = self
410-
.retrieve_activities(member_id, character_id, platform, mode, count, page)
422+
.retrieve_activities(
423+
member_id,
424+
character_id,
425+
platform,
426+
mode,
427+
count,
428+
page,
429+
)
411430
.await?;
412431

413432
if activities.is_none() {
@@ -493,7 +512,9 @@ impl ApiInterface {
493512
return Ok(None);
494513
} else {
495514
return Err(Error::ApiRequest {
496-
description: String::from("No response data from API Call."),
515+
description: String::from(
516+
"No response data from API Call.",
517+
),
497518
});
498519
}
499520
}
@@ -516,7 +537,8 @@ impl ApiInterface {
516537
instance_id = instance_id,
517538
);
518539

519-
let response: PGCRResponse = self.client.call_and_parse::<PGCRResponse>(&url).await?;
540+
let response: PGCRResponse =
541+
self.client.call_and_parse::<PGCRResponse>(&url).await?;
520542

521543
let data: DestinyPostGameCarnageReportData = match response.response {
522544
Some(e) => e,
@@ -525,7 +547,9 @@ impl ApiInterface {
525547
return Ok(None);
526548
} else {
527549
return Err(Error::ApiRequest {
528-
description: String::from("No response data from API Call."),
550+
description: String::from(
551+
"No response data from API Call.",
552+
),
529553
});
530554
}
531555
}

src/dcli/src/crucible.rs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ use std::{cmp::max, collections::hash_map::DefaultHasher, hash::Hasher};
3434
use std::{collections::HashMap, hash::Hash};
3535

3636
use crate::utils::{
37-
calculate_efficiency, calculate_kills_deaths_assists, calculate_kills_deaths_ratio,
37+
calculate_efficiency, calculate_kills_deaths_assists,
38+
calculate_kills_deaths_ratio,
3839
};
3940

4041
const PLAYER_START_BUFFER: u32 = 30;
@@ -55,7 +56,10 @@ pub struct CrucibleActivity {
5556
}
5657

5758
impl CrucibleActivity {
58-
pub fn get_member_performance(&self, member_id: &str) -> Option<&CruciblePlayerPerformance> {
59+
pub fn get_member_performance(
60+
&self,
61+
member_id: &str,
62+
) -> Option<&CruciblePlayerPerformance> {
5963
for t in self.teams.values() {
6064
for p in &t.player_performances {
6165
if p.player.member_id == member_id {
@@ -223,7 +227,8 @@ impl AggregateCruciblePerformances {
223227
performances: &[&CruciblePlayerPerformance],
224228
) -> AggregateCruciblePerformances {
225229
let mut out = AggregateCruciblePerformances::default();
226-
let mut extended = ExtendedCruciblePlayerActivityPerformances::default();
230+
let mut extended =
231+
ExtendedCruciblePlayerActivityPerformances::default();
227232

228233
out.total_activities = performances.len() as u32;
229234

@@ -252,7 +257,8 @@ impl AggregateCruciblePerformances {
252257
out.highest_deaths = max(p.stats.deaths, out.highest_deaths);
253258
out.highest_opponents_defeated =
254259
max(p.stats.opponents_defeated, out.highest_opponents_defeated);
255-
out.highest_efficiency = out.highest_efficiency.max(p.stats.efficiency);
260+
out.highest_efficiency =
261+
out.highest_efficiency.max(p.stats.efficiency);
256262
out.highest_kills_deaths_ratio = out
257263
.highest_kills_deaths_ratio
258264
.max(p.stats.kills_deaths_ratio);
@@ -283,9 +289,11 @@ impl AggregateCruciblePerformances {
283289

284290
#[allow(clippy::comparison_chain)]
285291
if streak > 0 {
286-
longest_win_streak = std::cmp::max(longest_win_streak, streak as u32);
292+
longest_win_streak =
293+
std::cmp::max(longest_win_streak, streak as u32);
287294
} else if streak < 0 {
288-
longest_loss_streak = std::cmp::max(longest_loss_streak, streak.abs() as u32);
295+
longest_loss_streak =
296+
std::cmp::max(longest_loss_streak, streak.abs() as u32);
289297
}
290298

291299
last_standing = p.stats.standing;
@@ -311,12 +319,18 @@ impl AggregateCruciblePerformances {
311319
e.weapon_kills_grenade,
312320
);
313321

314-
extended.highest_weapon_kills_melee =
315-
max(extended.highest_weapon_kills_melee, e.weapon_kills_melee);
316-
extended.highest_weapon_kills_super =
317-
max(extended.highest_weapon_kills_super, e.weapon_kills_super);
318-
extended.highest_all_medals_earned =
319-
max(extended.highest_all_medals_earned, e.all_medals_earned);
322+
extended.highest_weapon_kills_melee = max(
323+
extended.highest_weapon_kills_melee,
324+
e.weapon_kills_melee,
325+
);
326+
extended.highest_weapon_kills_super = max(
327+
extended.highest_weapon_kills_super,
328+
e.weapon_kills_super,
329+
);
330+
extended.highest_all_medals_earned = max(
331+
extended.highest_all_medals_earned,
332+
e.all_medals_earned,
333+
);
320334

321335
for m in &e.medals {
322336
let key = &m.medal.id;
@@ -356,7 +370,8 @@ impl AggregateCruciblePerformances {
356370
if ws.kills == 0 {
357371
0.0
358372
} else {
359-
(ws.precision_kills as f32 / ws.kills as f32) * 100.0
373+
(ws.precision_kills as f32 / ws.kills as f32)
374+
* 100.0
360375
}
361376
};
362377
}
@@ -367,11 +382,13 @@ impl AggregateCruciblePerformances {
367382
out.longest_loss_streak = longest_loss_streak;
368383

369384
if has_extended {
370-
let mut medals: Vec<MedalStat> = medal_hash.into_iter().map(|(_id, m)| m).collect();
385+
let mut medals: Vec<MedalStat> =
386+
medal_hash.into_iter().map(|(_id, m)| m).collect();
371387

372388
medals.sort_by(|a, b| b.count.cmp(&a.count));
373389

374-
let mut weapons: Vec<WeaponStat> = weapon_hash.into_iter().map(|(_id, w)| w).collect();
390+
let mut weapons: Vec<WeaponStat> =
391+
weapon_hash.into_iter().map(|(_id, w)| w).collect();
375392
weapons.sort_by(|a, b| b.kills.cmp(&a.kills));
376393

377394
extended.medals = medals;
@@ -383,11 +400,14 @@ impl AggregateCruciblePerformances {
383400
}
384401

385402
if out.total_activities > 0 {
386-
out.win_rate = (out.wins as f32 / out.total_activities as f32) * 100.0;
403+
out.win_rate =
404+
(out.wins as f32 / out.total_activities as f32) * 100.0;
387405
}
388406

389-
out.efficiency = calculate_efficiency(out.kills, out.deaths, out.assists);
390-
out.kills_deaths_ratio = calculate_kills_deaths_ratio(out.kills, out.deaths);
407+
out.efficiency =
408+
calculate_efficiency(out.kills, out.deaths, out.assists);
409+
out.kills_deaths_ratio =
410+
calculate_kills_deaths_ratio(out.kills, out.deaths);
391411
out.kills_deaths_assists =
392412
calculate_kills_deaths_assists(out.kills, out.deaths, out.assists);
393413

src/dcli/src/enums/character.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ impl FromStr for CharacterClassSelection {
5454
}
5555

5656
/****************CharacterGender *******************/
57-
#[derive(PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr, Debug)]
57+
#[derive(
58+
PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr, Debug,
59+
)]
5860
#[repr(u32)]
5961
pub enum CharacterGender {
6062
Masculine = 0,
@@ -87,7 +89,9 @@ impl fmt::Display for CharacterGender {
8789
}
8890

8991
/****************CharacterClass *******************/
90-
#[derive(PartialEq, Eq, Hash, Clone, Copy, Serialize_repr, Deserialize_repr, Debug)]
92+
#[derive(
93+
PartialEq, Eq, Hash, Clone, Copy, Serialize_repr, Deserialize_repr, Debug,
94+
)]
9195
#[repr(u32)]
9296
pub enum CharacterClass {
9397
Titan = 0,
@@ -140,7 +144,9 @@ impl fmt::Display for CharacterClass {
140144

141145
/*************************** CharacterRace *************************/
142146

143-
#[derive(PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr, Debug)]
147+
#[derive(
148+
PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr, Debug,
149+
)]
144150
#[repr(u32)]
145151
pub enum CharacterRace {
146152
Human = 0,

src/dcli/src/enums/moment.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ impl Moment {
9292
Moment::SeasonOfTheForge => Utc.ymd(2018, 12, 4).and_hms(18, 0, 0),
9393
Moment::SeasonOfTheDrifter => Utc.ymd(2019, 3, 5).and_hms(18, 0, 0),
9494
Moment::SeasonOfOpulence => Utc.ymd(2019, 6, 4).and_hms(18, 0, 0),
95-
Moment::SeasonOfTheUndying => Utc.ymd(2019, 10, 1).and_hms(18, 0, 0),
95+
Moment::SeasonOfTheUndying => {
96+
Utc.ymd(2019, 10, 1).and_hms(18, 0, 0)
97+
}
9698
Moment::SeasonOfDawn => Utc.ymd(2019, 12, 10).and_hms(18, 0, 0),
9799
Moment::SeasonOfTheWorthy => Utc.ymd(2020, 3, 10).and_hms(18, 0, 0),
98100
Moment::SeasonOfArrivals => Utc.ymd(2020, 6, 9).and_hms(18, 0, 0),
@@ -197,7 +199,9 @@ impl DateTimePeriod {
197199
self.end
198200
}
199201

200-
pub fn with_start_time(start: DateTime<Utc>) -> Result<DateTimePeriod, Error> {
202+
pub fn with_start_time(
203+
start: DateTime<Utc>,
204+
) -> Result<DateTimePeriod, Error> {
201205
let end = Utc::now();
202206

203207
if start > end {

src/dcli/src/enums/platform.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ use std::str::FromStr;
2626
use serde_repr::{Deserialize_repr, Serialize_repr};
2727

2828
///Destiny 2 Platforms
29-
#[derive(PartialEq, Clone, Copy, Debug, Hash, Eq, Deserialize_repr, Serialize_repr)]
29+
#[derive(
30+
PartialEq, Clone, Copy, Debug, Hash, Eq, Deserialize_repr, Serialize_repr,
31+
)]
3032
#[repr(i32)]
3133
pub enum Platform {
3234
///Xbox

src/dcli/src/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ impl Display for Error {
162162
Error::DateTimePeriodOrder => {
163163
write!(f, "Start date must be before end date.")
164164
},
165-
166-
167165
}
168166
}
169167
}

0 commit comments

Comments
 (0)