From 8a695b1aedbea93c0684d7f4523b83961a70becd Mon Sep 17 00:00:00 2001 From: ev3nvy <12035264+ev3nvy@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:23:53 +0100 Subject: [PATCH 1/5] use number seperator for magic bytes Doesn't make much difference, and it was even better before IMO. Still better than specifically ignoring that specific clippy rule just for this line. --- src/parser/header.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/header.rs b/src/parser/header.rs index d70fd24..6f3b985 100644 --- a/src/parser/header.rs +++ b/src/parser/header.rs @@ -91,7 +91,7 @@ impl Header { // N A M R (RMAN bacwards because I am reading this as an u32, instead // of as an array of chars) - if magic != 0x4E414D52 { + if magic != 0x4E_41_4D_52 { return Err(ManifestError::InvalidMagicBytes(magic)); } From e8ffe7495446b5ba2843befe3ecede61380c4c8c Mon Sep 17 00:00:00 2001 From: ev3nvy <12035264+ev3nvy@users.noreply.github.com> Date: Tue, 7 Feb 2023 01:25:44 +0100 Subject: [PATCH 2/5] fix `clippy::doc_markdown` warnings --- src/entries/bundle_entry.rs | 2 +- src/entries/chunk_entry.rs | 2 +- src/entries/directory_entry.rs | 2 +- src/entries/file_entry.rs | 2 +- src/entries/key_entry.rs | 2 +- src/entries/language_entry.rs | 2 +- src/entries/param_entry.rs | 2 +- src/lib.rs | 2 +- src/parser/header.rs | 7 ++++--- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/entries/bundle_entry.rs b/src/entries/bundle_entry.rs index 4b5e8ed..96e7aa6 100644 --- a/src/entries/bundle_entry.rs +++ b/src/entries/bundle_entry.rs @@ -5,7 +5,7 @@ use super::chunk_entry::ChunkEntry; /// Single bundle entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the BundleEntry. +/// persistent structure for the `BundleEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/chunk_entry.rs b/src/entries/chunk_entry.rs index 31796cb..5f14ae9 100644 --- a/src/entries/chunk_entry.rs +++ b/src/entries/chunk_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::Chunk; /// Single chunk entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the ChunkEntry. +/// persistent structure for the `ChunkEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/directory_entry.rs b/src/entries/directory_entry.rs index 4dbc69b..00ea112 100644 --- a/src/entries/directory_entry.rs +++ b/src/entries/directory_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::Directory; /// Single directory entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the DirectoryEntry. +/// persistent structure for the `DirectoryEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/file_entry.rs b/src/entries/file_entry.rs index 2a164cc..d5460ef 100644 --- a/src/entries/file_entry.rs +++ b/src/entries/file_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::File; /// Single file entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the FileEntry. +/// persistent structure for the `FileEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/key_entry.rs b/src/entries/key_entry.rs index 77614f0..3d4da92 100644 --- a/src/entries/key_entry.rs +++ b/src/entries/key_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::Key; /// Single key entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the KeyEntry. +/// persistent structure for the `KeyEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/language_entry.rs b/src/entries/language_entry.rs index d7ae1f5..6a3bdd3 100644 --- a/src/entries/language_entry.rs +++ b/src/entries/language_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::Language; /// Single language entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the LanguageEntry. +/// persistent structure for the `LanguageEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/entries/param_entry.rs b/src/entries/param_entry.rs index 8ebc8e5..ad8aea0 100644 --- a/src/entries/param_entry.rs +++ b/src/entries/param_entry.rs @@ -3,7 +3,7 @@ use crate::generated::rman::Param; /// Single param entry object. /// /// This is identical to the schema in [rman-schema][rman-schema] and exists to provide a -/// persistent structure for the ParamEntry. +/// persistent structure for the `ParamEntry`. /// /// [rman-schema]: https://github.com/ev3nvy/rman-schema #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/src/lib.rs b/src/lib.rs index 14673ac..af7324f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,7 +122,7 @@ //! This crate: //! - reads the `.manifest` file, and verifies it's a valid `rman` file, //! - decompresses the containing data which was compressed using [zstd][zstd], -//! - parses the decompressed [FlatBuffer][flatbuffers] data, +//! - parses the decompressed [flatbuffer data][flatbuffers], //! - stores all of the parsed data on [`ManifestData`][crate::ManifestData], //! - combines the data into a vector of downloadable [`File`][crate::File]s, //! - provides a function to [`download`][crate::File::download] specific files. diff --git a/src/parser/header.rs b/src/parser/header.rs index 6f3b985..8f191d2 100644 --- a/src/parser/header.rs +++ b/src/parser/header.rs @@ -68,11 +68,12 @@ impl Header { /// [`version_error`](index.html#feature-version_error) is enabled, the error /// [`InvalidMinor`][crate::ManifestError::InvalidMinor] is returned. /// - /// If offset is smaller or larger than the file, the error + /// If [`offset`](Header::offset) is smaller or larger than the file, the error /// [`InvalidOffset`][crate::ManifestError::InvalidOffset] is returned. /// - /// If compressed_size is smaller or larger than the file, the error - /// [`CompressedSizeTooLarge`][crate::ManifestError::CompressedSizeTooLarge] is returned. + /// If [`compressed_size`](Header::compressed_size) is smaller or larger than the file, the + /// error [`CompressedSizeTooLarge`][crate::ManifestError::CompressedSizeTooLarge] is + /// returned. pub fn from_reader(reader: &mut R) -> Result where R: Read + Seek, From 286a2c24d044ed2d6d6722da9404c803c24f7d6c Mon Sep 17 00:00:00 2001 From: ev3nvy <12035264+ev3nvy@users.noreply.github.com> Date: Tue, 7 Feb 2023 01:28:03 +0100 Subject: [PATCH 3/5] fix `clippy::implicit_clone` warnings --- src/file.rs | 10 +++++----- src/parser/manifest.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/file.rs b/src/file.rs index 747c9ee..2ded7f7 100644 --- a/src/file.rs +++ b/src/file.rs @@ -75,12 +75,12 @@ impl File { chunk_entries: &HashMap, ) -> Result { let id = file.id; - let name = file.name.to_owned(); + let name = file.name.clone(); let permissions = file.permissions; let size = file.size; - let symlink = file.symlink.to_owned(); + let symlink = file.symlink.clone(); let language_mask = file.language_mask; - let chunk_ids = file.chunk_ids.to_owned(); + let chunk_ids = &file.chunk_ids; let mut directory_id = file.directory_id; let mut path = String::new(); @@ -104,14 +104,14 @@ impl File { } if let Some(lang_name) = language_entries.get(&(i + 1)) { - languages.push(lang_name.to_owned()); + languages.push(lang_name.clone()); } } let mut chunks = Vec::new(); for chunk_id in chunk_ids { - let Some(chunk) = chunk_entries.get(&chunk_id) else { + let Some(chunk) = chunk_entries.get(chunk_id) else { let message = format!("Could not find a chunk with the following id: \"{chunk_id}\"."); return Err(ManifestError::FileParseError(message)); }; diff --git a/src/parser/manifest.rs b/src/parser/manifest.rs index 8161be8..cb2e116 100644 --- a/src/parser/manifest.rs +++ b/src/parser/manifest.rs @@ -85,14 +85,14 @@ impl ManifestData { fn map_languages(language_entries: &[LanguageEntry]) -> HashMap { language_entries .iter() - .map(|l| (l.id, l.name.to_owned())) + .map(|l| (l.id, l.name.clone())) .collect() } fn map_directories(directory_entries: &[DirectoryEntry]) -> HashMap { directory_entries .iter() - .map(|d| (d.id, (d.name.to_owned(), d.parent_id))) + .map(|d| (d.id, (d.name.clone(), d.parent_id))) .collect() } From 1df2b22131acaf847967551abae44e8366ef07e6 Mon Sep 17 00:00:00 2001 From: ev3nvy <12035264+ev3nvy@users.noreply.github.com> Date: Tue, 7 Feb 2023 01:30:28 +0100 Subject: [PATCH 4/5] fix `clippy::future_not_send` warnings --- src/file.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/file.rs b/src/file.rs index 2ded7f7..bf609c8 100644 --- a/src/file.rs +++ b/src/file.rs @@ -160,7 +160,11 @@ impl File { /// # Examples /// /// See [downloading a file](index.html#example-downloading-a-file). - pub async fn download(&self, mut writer: W, bundle_url: U) -> Result<()> { + pub async fn download( + &self, + mut writer: W, + bundle_url: U, + ) -> Result<()> { let client = Client::new(); for (bundle_id, offset, uncompressed_size, compressed_size) in &self.chunks { From d6ebdce110f0557887717fcea85c7cbad126ff38 Mon Sep 17 00:00:00 2001 From: ev3nvy <12035264+ev3nvy@users.noreply.github.com> Date: Tue, 7 Feb 2023 01:31:20 +0100 Subject: [PATCH 5/5] enable pedantic and nursery clippy lints --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index af7324f..4abdec3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![deny(missing_docs)] #![deny(missing_debug_implementations)] -#![deny(clippy::all, clippy::unwrap_used)] +#![deny(clippy::all, clippy::pedantic, clippy::nursery, clippy::unwrap_used)] +#![allow(clippy::module_name_repetitions, clippy::similar_names)] //! # rman //!