Applied clippy suggestions

This commit is contained in:
G2-Games 2023-12-11 02:42:13 -06:00
parent 5000d24a77
commit 045cea90bf
7 changed files with 20 additions and 24 deletions

View file

@ -179,7 +179,7 @@ impl Player {
match msg.view() {
gst::MessageView::Eos(_) => {}
gst::MessageView::StreamStart(_) => println!("Stream start"),
gst::MessageView::Error(e) => {
gst::MessageView::Error(_) => {
playbin_bus_ctrl
.write()
.unwrap()
@ -201,7 +201,7 @@ impl Player {
.unwrap()
.set_state(gst::State::Paused)
.unwrap();
} else if *paused_bus_ctrl.read().unwrap() == false {
} else if !(*paused_bus_ctrl.read().unwrap()) {
*buffer_bus_ctrl.write().unwrap() = None;
playbin_bus_ctrl
.write()
@ -377,19 +377,17 @@ impl Player {
/// Seek absolutely
pub fn seek_to(&mut self, target_pos: Duration) -> Result<(), Box<dyn Error>> {
let start;
if self.start.read().unwrap().is_none() {
let start = if self.start.read().unwrap().is_none() {
return Err("Failed to seek: No START time".into());
} else {
start = self.start.read().unwrap().unwrap();
}
self.start.read().unwrap().unwrap()
};
let end;
if self.end.read().unwrap().is_none() {
let end = if self.end.read().unwrap().is_none() {
return Err("Failed to seek: No END time".into());
} else {
end = self.end.read().unwrap().unwrap();
}
self.end.read().unwrap().unwrap()
};
let adjusted_target = target_pos + start;
let clamped_target = adjusted_target.clamp(start, end);

View file

@ -1,15 +1,13 @@
use std::path::PathBuf;
use chrono::{DateTime, TimeZone, Utc};
pub fn get_bytes<const S: usize>(iterator: &mut std::vec::IntoIter<u8>) -> [u8; S] {
let mut bytes = [0; S];
for i in 0..S {
bytes[i] = iterator.next().unwrap();
for byte in bytes.iter_mut().take(S) {
*byte = iterator.next().unwrap();
}
return bytes;
bytes
}
pub fn get_bytes_vec(iterator: &mut std::vec::IntoIter<u8>, number: usize) -> Vec<u8> {
@ -19,7 +17,7 @@ pub fn get_bytes_vec(iterator: &mut std::vec::IntoIter<u8>, number: usize) -> Ve
bytes.push(iterator.next().unwrap());
}
return bytes;
bytes
}
/// Converts the windows DateTime into Chrono DateTime
@ -28,7 +26,7 @@ pub fn get_datetime(iterator: &mut std::vec::IntoIter<u8>, topbyte: bool) -> Dat
if topbyte {
// Zero the topmost byte
datetime_i64 = datetime_i64 & 0x00FFFFFFFFFFFFFFF;
datetime_i64 &= 0x00FFFFFFFFFFFFFFF;
}
if datetime_i64 <= 0 {

View file

@ -1,9 +1,9 @@
use std::path::PathBuf;
use std::path::Path;
use crate::music_storage::library::Song;
pub trait ExternalLibrary {
fn from_file(file: &PathBuf) -> Self;
fn from_file(file: &Path) -> Self;
fn write(&self) {
unimplemented!();
}

View file

@ -1,5 +1,5 @@
use std::collections::BTreeMap;
use std::{fs::File, io::Read, path::PathBuf, time::Duration};
use std::{fs::File, io::Read, path::Path, time::Duration};
use crate::music_storage::db_reader::common::{get_bytes, get_bytes_vec};
use crate::music_storage::db_reader::extern_library::ExternalLibrary;
@ -19,7 +19,7 @@ pub struct FoobarPlaylist {
impl ExternalLibrary for FoobarPlaylist {
/// Reads the entire MusicBee library and returns relevant values
/// as a `Vec` of `Song`s
fn from_file(file: &PathBuf) -> Self {
fn from_file(file: &Path) -> Self {
let mut f = File::open(file).unwrap();
let mut buffer = Vec::new();
let mut retrieved_songs: Vec<FoobarPlaylistTrack> = Vec::new();

View file

@ -1,4 +1,4 @@
pub fn meta_offset(metadata: &Vec<u8>, offset: usize) -> String {
pub fn meta_offset(metadata: &[u8], offset: usize) -> String {
let mut result_vec = Vec::new();
let mut i = offset;

View file

@ -29,7 +29,7 @@ impl MusicBeeDatabase {
// Get the song count from the first 4 bytes
// and then right shift it by 8 for some reason
let mut database_song_count = i32::from_le_bytes(get_bytes(&mut buf_iter));
database_song_count = database_song_count >> 8;
database_song_count >>= 8;
let mut song_count = 0;
loop {

View file

@ -28,7 +28,7 @@ impl XmlLibrary {
}
}
impl ExternalLibrary for XmlLibrary {
fn from_file(file: &PathBuf) -> Self {
fn from_file(file: &Path) -> Self {
let mut reader = Reader::from_file(file).unwrap();
reader.trim_text(true);
//count every event, for fun ig?