release clippy fixes
This commit is contained in:
@@ -208,6 +208,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
6
src/cache/mod.rs
vendored
6
src/cache/mod.rs
vendored
@@ -9,6 +9,12 @@ pub struct SimpleCache<T: Clone> {
|
||||
collection: BTreeMap<u32, T>,
|
||||
}
|
||||
|
||||
impl<T: Clone> Default for SimpleCache<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> SimpleCache<T> {
|
||||
/// Create new Empty Cache
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -23,6 +23,12 @@ pub struct ImageSimulator {
|
||||
buffer: Framebuffer<BinaryColor, RawU1, BigEndian, WIDTH, HEIGHT, { WIDTH * HEIGHT }>,
|
||||
}
|
||||
|
||||
impl Default for ImageSimulator {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ImageSimulator {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
@@ -63,7 +69,7 @@ impl ImageSimulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(alliance) = &kill.victim.alliance {
|
||||
let bw_vec = rgb_to_bw_dithered(&alliance.logo);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, alliance.logo.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, alliance.logo.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -72,7 +78,7 @@ impl ImageSimulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgb_to_bw_dithered(&ship.icon);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -132,7 +138,7 @@ impl ImageSimulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(character) = &kill.victim.character {
|
||||
let bw_vec = rgb_to_bw_dithered(&character.portrait);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, character.portrait.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, character.portrait.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -141,7 +147,7 @@ impl ImageSimulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgb_to_bw_dithered(&ship.icon);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -234,7 +240,7 @@ impl KillDisplay for ImageSimulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(alliance) = &kill.victim.alliance {
|
||||
let bw_vec = rgb_to_bw_dithered(&alliance.logo);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, alliance.logo.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, alliance.logo.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -243,7 +249,7 @@ impl KillDisplay for ImageSimulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgb_to_bw_dithered(&ship.icon);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -303,7 +309,7 @@ impl KillDisplay for ImageSimulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(character) = &kill.victim.character {
|
||||
let bw_vec = rgb_to_bw_dithered(&character.portrait);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, character.portrait.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, character.portrait.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -312,7 +318,7 @@ impl KillDisplay for ImageSimulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgb_to_bw_dithered(&ship.icon);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<BinaryColor>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
|
||||
@@ -22,6 +22,12 @@ pub struct Simulator {
|
||||
window: Window,
|
||||
}
|
||||
|
||||
impl Default for Simulator {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Simulator {
|
||||
pub fn new() -> Self {
|
||||
let display = SimulatorDisplay::<Gray8>::new(Size::new(WIDTH as u32, HEIGHT as u32));
|
||||
@@ -60,7 +66,7 @@ impl Simulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(alliance) = &kill.victim.alliance {
|
||||
let bw_vec = rgbimage_to_gray8(&alliance.logo);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, alliance.logo.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, alliance.logo.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -69,7 +75,7 @@ impl Simulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgbimage_to_gray8(&ship.icon);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -129,7 +135,7 @@ impl Simulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(character) = &kill.victim.character {
|
||||
let bw_vec = rgbimage_to_gray8(&character.portrait);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, character.portrait.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, character.portrait.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -138,7 +144,7 @@ impl Simulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgbimage_to_gray8(&ship.icon);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -230,7 +236,7 @@ impl KillDisplay for Simulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(alliance) = &kill.victim.alliance {
|
||||
let bw_vec = rgbimage_to_gray8(&alliance.logo);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, alliance.logo.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, alliance.logo.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -239,7 +245,7 @@ impl KillDisplay for Simulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgbimage_to_gray8(&ship.icon);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -299,7 +305,7 @@ impl KillDisplay for Simulator {
|
||||
// Draw Alliance logo (64x64) if present
|
||||
if let Some(character) = &kill.victim.character {
|
||||
let bw_vec = rgbimage_to_gray8(&character.portrait);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, character.portrait.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, character.portrait.width());
|
||||
Image::new(&logo_raw, Point::new(x, y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -308,7 +314,7 @@ impl KillDisplay for Simulator {
|
||||
// Draw Ship icon (64x64) if present
|
||||
if let Some(ship) = &kill.victim.ship {
|
||||
let bw_vec = rgbimage_to_gray8(&ship.icon);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width() as u32);
|
||||
let logo_raw = ImageRaw::<Gray8>::new(&bw_vec, ship.icon.width());
|
||||
Image::new(&logo_raw, Point::new(x + 64 + 4, current_y))
|
||||
.draw(&mut self.buffer)
|
||||
.ok();
|
||||
@@ -375,5 +381,5 @@ fn rgbimage_to_gray8(raw_img: &RgbImage) -> Vec<u8> {
|
||||
gray_data.push(luma);
|
||||
}
|
||||
|
||||
return gray_data;
|
||||
gray_data
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub enum DisplayRotation {
|
||||
/// count the number of bytes per line knowing that it may contains padding bits
|
||||
const fn line_bytes(width: u32, bits_per_pixel: usize) -> usize {
|
||||
// round to upper 8 bit count
|
||||
(width as usize * bits_per_pixel + 7) / 8
|
||||
(width as usize * bits_per_pixel).div_ceil(8)
|
||||
}
|
||||
|
||||
/// Display buffer used for drawing with embedded graphics
|
||||
|
||||
@@ -47,6 +47,12 @@ pub struct KillInfoBuilder {
|
||||
corporation_id: u32,
|
||||
}
|
||||
|
||||
impl Default for KillInfoBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl KillInfoBuilder {
|
||||
/// Creates a new builder with default settings.
|
||||
pub fn new() -> KillInfoBuilder {
|
||||
@@ -79,16 +85,14 @@ impl KillInfoBuilder {
|
||||
let main_attacker: Option<Individual> =
|
||||
self.find_main_attacker(&attacker_list).and_then(|a| {
|
||||
// Try to build the Individual. If it fails, return None
|
||||
match Individual::build_with_esi(
|
||||
Individual::build_with_esi(
|
||||
esi,
|
||||
a.character_id,
|
||||
a.corporation_id,
|
||||
a.alliance_id,
|
||||
a.ship_id,
|
||||
) {
|
||||
Ok(ind) => Some(ind),
|
||||
Err(_) => None, // ignore errors here
|
||||
}
|
||||
)
|
||||
.ok()
|
||||
});
|
||||
|
||||
let victim = Individual::build_with_esi(
|
||||
@@ -118,7 +122,7 @@ impl KillInfoBuilder {
|
||||
/// the attacker with the highest damage done.
|
||||
pub fn find_main_attacker(
|
||||
&self,
|
||||
attacker_list: &Vec<KillmailAttacker>,
|
||||
attacker_list: &[KillmailAttacker],
|
||||
) -> Option<KillmailAttacker> {
|
||||
if attacker_list.is_empty() {
|
||||
return None;
|
||||
|
||||
@@ -16,7 +16,7 @@ pub mod services;
|
||||
/// \[XXXXX210\]\[76543210\]...\[76543210\] | height
|
||||
/// \[XXXXX210\]\[76543210\]...\[76543210\] v
|
||||
pub const fn buffer_len(width: usize, height: usize) -> usize {
|
||||
(width + 7) / 8 * height
|
||||
width.div_ceil(8) * height
|
||||
}
|
||||
|
||||
use embedded_hal::spi::{Mode, Phase, Polarity};
|
||||
|
||||
@@ -26,10 +26,10 @@ pub mod services;
|
||||
pub mod epd;
|
||||
|
||||
pub const fn buffer_len(width: usize, height: usize) -> usize {
|
||||
(width + 7) / 8 * height
|
||||
width.div_ceil(8) * height
|
||||
}
|
||||
|
||||
fn main() -> () {
|
||||
fn main() {
|
||||
// Pick the display based on compile-time feature
|
||||
#[cfg(feature = "simulator")]
|
||||
let display = display::Simulator::new();
|
||||
|
||||
@@ -116,6 +116,12 @@ pub struct EsiClient {
|
||||
ship_image_cache: ImageCache,
|
||||
}
|
||||
|
||||
impl Default for EsiClient {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl EsiClient {
|
||||
/// Creates a new `EsiClient` instance with default configuration.
|
||||
///
|
||||
|
||||
@@ -131,6 +131,12 @@ pub struct ZkillClient {
|
||||
client: Client,
|
||||
}
|
||||
|
||||
impl Default for ZkillClient {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ZkillClient {
|
||||
/// Creates a new [`ZkillClient`] with a configured `reqwest::Client`.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user