From 4dbad33000129655bebb6c7bc7c815ab17690cd0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 4 Feb 2025 13:21:22 +0000 Subject: [PATCH] Make clippy happy --- src/config.rs | 12 ++++++------ src/database/connection.rs | 4 ++-- src/database/mod.rs | 18 +++++++++--------- src/database/recovery.rs | 4 ++-- src/database/searcher.rs | 4 ++-- src/events.rs | 12 ++++++++---- src/index/encrypted_dir.rs | 25 ++++++++++++------------- src/index/encrypted_stream.rs | 6 +++--- 8 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2be25b7..36c5070 100644 --- a/src/config.rs +++ b/src/config.rs @@ -68,7 +68,7 @@ impl SearchConfig { /// # Arguments /// /// * `limit` - The max number of contextual events to return in the search - /// result. + /// result. pub fn before_limit(&mut self, limit: usize) -> &mut Self { self.before_limit = limit; self @@ -80,7 +80,7 @@ impl SearchConfig { /// # Arguments /// /// * `limit` - The max number of contextual events to return in the search - /// result. + /// result. pub fn after_limit(&mut self, limit: usize) -> &mut Self { self.after_limit = limit; self @@ -91,7 +91,7 @@ impl SearchConfig { /// # Arguments /// /// * `order_by_recency` - Flag to determine if we should order by recency. - /// result. + /// result. pub fn order_by_recency(&mut self, order_by_recency: bool) -> &mut Self { self.order_by_recency = order_by_recency; self @@ -115,7 +115,7 @@ impl SearchConfig { } /// The point to return events from. If given, this should be a next_batch - /// result from a previous search. + /// result from a previous search. pub fn next_batch(&mut self, token: Uuid) -> &mut Self { self.next_batch = Some(token); self @@ -317,8 +317,8 @@ impl LoadConfig { /// # Arguments /// /// * `event_id` - An event id of a previous event returned by this - /// method. If set events that are older than the event with the given - /// event ID will be returned. + /// method. If set events that are older than the event with the given + /// event ID will be returned. #[allow(clippy::wrong_self_convention)] pub fn from_event>(mut self, event_id: E) -> Self { self.from_event = Some(event_id.into()); diff --git a/src/database/connection.rs b/src/database/connection.rs index 09e3351..3c667c0 100644 --- a/src/database/connection.rs +++ b/src/database/connection.rs @@ -117,7 +117,7 @@ impl Connection { /// # Arguments /// /// * `load_config` - Configuration deciding which events and how many of - /// them should be loaded. + /// them should be loaded. /// /// # Examples /// @@ -127,7 +127,7 @@ impl Connection { /// ``` /// /// Returns a list of tuples containing the serialized events and the - /// profile of the sender at the time when the event was sent. + /// profile of the sender at the time when the event was sent. pub fn load_file_events( &self, load_config: &LoadConfig, diff --git a/src/database/mod.rs b/src/database/mod.rs index 232ce52..d3bbfdb 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -87,7 +87,7 @@ impl Database { /// # Arguments /// /// * `path` - The directory where the database will be stored in. This - /// should be an empty directory if a new database should be created. + /// should be an empty directory if a new database should be created. pub fn new>(path: P) -> Result where PathBuf: std::convert::From

, @@ -100,7 +100,7 @@ impl Database { /// # Arguments /// /// * `path` - The directory where the database will be stored in. This - /// should be an empty directory if a new database should be created. + /// should be an empty directory if a new database should be created. /// * `config` - Configuration that changes the behaviour of the database. pub fn new_with_config>(path: P, config: &Config) -> Result where @@ -207,15 +207,15 @@ impl Database { /// Change the passphrase of the Seshat database. /// /// Note that this consumes the database object and any searcher objects - /// can't be used anymore. A new database will have to be opened and new - /// searcher objects as well. + /// can't be used anymore. A new database will have to be opened and new + /// searcher objects as well. /// /// # Arguments /// /// * `path` - The directory where the database will be stored in. This - /// should be an empty directory if a new database should be created. + /// should be an empty directory if a new database should be created. /// * `new_passphrase` - The passphrase that should be used instead of the - /// current one. + /// current one. #[cfg(feature = "encryption")] pub fn change_passphrase(self, new_passphrase: &str) -> Result<()> { match &self.config.passphrase { @@ -430,10 +430,10 @@ impl Database { /// /// * `events` - The events that will be added. /// * `new_checkpoint` - A checkpoint that states where we need to continue - /// fetching events from the room history. This checkpoint will be - /// persisted in the database. + /// fetching events from the room history. This checkpoint will be + /// persisted in the database. /// * `old_checkpoint` - The checkpoint that was used to fetch the given - /// events. This checkpoint will be removed from the database. + /// events. This checkpoint will be removed from the database. pub fn add_historic_events( &self, events: Vec<(Event, Profile)>, diff --git a/src/database/recovery.rs b/src/database/recovery.rs index c6a6022..dc9f004 100644 --- a/src/database/recovery.rs +++ b/src/database/recovery.rs @@ -74,7 +74,7 @@ impl RecoveryDatabase { /// # Arguments /// /// * `path` - The directory where the database will be stored in. This - /// should be an empty directory if a new database should be created. + /// should be an empty directory if a new database should be created. pub fn new>(path: P) -> Result where PathBuf: std::convert::From

, @@ -87,7 +87,7 @@ impl RecoveryDatabase { /// # Arguments /// /// * `path` - The directory where the database will be stored in. This - /// should be an empty directory if a new database should be created. + /// should be an empty directory if a new database should be created. /// /// * `config` - Configuration that changes the behaviour of the database. pub fn new_with_config>(path: P, config: &Config) -> Result diff --git a/src/database/searcher.rs b/src/database/searcher.rs index 3ad01a9..fbb2501 100644 --- a/src/database/searcher.rs +++ b/src/database/searcher.rs @@ -75,10 +75,10 @@ impl Searcher { /// /// * `term` - The search term that should be used to search the index. /// * `config` - A SearchConfig that will modify what the search result - /// should contain. + /// should contain. /// /// Returns a tuple of the count of matching documents and a list of - /// `SearchResult`. + /// `SearchResult`. pub fn search(&self, term: &str, config: &SearchConfig) -> Result { let search_result = self.inner.search(term, config)?; diff --git a/src/events.rs b/src/events.rs index 37e1d32..547c993 100644 --- a/src/events.rs +++ b/src/events.rs @@ -118,7 +118,7 @@ impl Dummy for Event { EventType::Message, "Hello world", Some("m.text"), - &format!("${}:{}", (0..std::u64::MAX).fake::(), &domain), + &format!("${}:{}", (0..u64::MAX).fake::(), &domain), &format!( "@{}:{}", Username(EN).fake::(), @@ -155,12 +155,12 @@ impl Event { /// /// * `event_type` - The type of the event. /// * `content_value` - The plain text value of the content, body for a - /// message event, topic for a topic event and name for a name event. + /// message event, topic for a topic event and name for a name event. /// * `event_id` - The unique identifier of the event. /// * `sender` - The unique identifier of the event author. /// * `server_ts` - The timestamp of the event. /// * `room_id` - The unique identifier of the room that the event belongs - /// to. + /// to. /// * `source` - The serialized version of the event. #[allow(clippy::too_many_arguments)] pub fn new( @@ -212,6 +212,7 @@ impl Profile { } #[cfg(test)] +#[allow(missing_docs)] pub static EVENT_SOURCE: &str = r#"{ "content": { "body": "Test message, msgtype: m.text" @@ -221,11 +222,12 @@ pub static EVENT_SOURCE: &str = r#"{ "sender": "@example2:localhost", "type": "m.room.message", "unsigned": {"age": 43289803095}, - "user_id": "@example2:localhost", + "user_id": "@examp le2:localhost", "age": 43289803095 }"#; #[cfg(test)] +#[allow(missing_docs)] pub static TOPIC_EVENT_SOURCE: &str = r#"{ "content": { "topic": "Test topic" @@ -241,6 +243,7 @@ pub static TOPIC_EVENT_SOURCE: &str = r#"{ #[cfg(test)] lazy_static! { + #[allow(missing_docs)] pub static ref EVENT: Event = Event::new( EventType::Message, "Test message", @@ -255,6 +258,7 @@ lazy_static! { #[cfg(test)] lazy_static! { + #[allow(missing_docs)] pub static ref TOPIC_EVENT: Event = Event::new( EventType::Topic, "Test topic", diff --git a/src/index/encrypted_dir.rs b/src/index/encrypted_dir.rs index 8320612..3e5acdf 100644 --- a/src/index/encrypted_dir.rs +++ b/src/index/encrypted_dir.rs @@ -174,25 +174,25 @@ impl EncryptedMmapDirectory { }) } /// Open a encrypted mmap directory. If the directory is empty a new - /// directory key will be generated and encrypted with the given passphrase. + /// directory key will be generated and encrypted with the given passphrase. /// /// If a new store is created, this method will randomly generated a new - /// store key and encrypted using the given passphrase. + /// store key and encrypted using the given passphrase. /// /// # Arguments /// /// * `path` - The path where the directory should reside in. /// * `passphrase` - The passphrase that was used to encrypt our directory - /// or the one that will be used to encrypt our directory. + /// or the one that will be used to encrypt our directory. /// * `key_derivation_count` - The number of iterations that our key - /// derivation function should use. Can't be lower than 1, should be chosen - /// as high as possible, depending on how much time is acceptable for the - /// caller to wait. Is only used when a new store is created. The count will - /// be stored with the store key. + /// derivation function should use. Can't be lower than 1, should be chosen + /// as high as possible, depending on how much time is acceptable for the + /// caller to wait. Is only used when a new store is created. The count will + /// be stored with the store key. /// /// Returns an error if the path does not exist, if it is not a directory or - /// if there was an error when trying to decrypt the directory key e.g. the - /// given passphrase was incorrect. + /// if there was an error when trying to decrypt the directory key e.g. the + /// given passphrase was incorrect. pub fn open_or_create>( path: P, passphrase: &str, @@ -238,9 +238,8 @@ impl EncryptedMmapDirectory { /// * `passphrase` - The passphrase that was used to encrypt our directory. /// /// Returns an error if the path does not exist, if it is not a directory or - /// if there was an error when trying to decrypt the directory key e.g. the - /// given passphrase was incorrect. - + /// if there was an error when trying to decrypt the directory key e.g. the + /// given passphrase was incorrect. // This isn't currently used anywhere, but it will make sense if the // EncryptedMmapDirectory gets upstreamed. #[allow(dead_code)] @@ -266,7 +265,7 @@ impl EncryptedMmapDirectory { /// * `old_passphrase` - The currently used passphrase. /// * `new_passphrase` - The passphrase that should be used from now on. /// * `new_key_derivation_count` - The key derivation count that should be - /// used for the re-encrypted store key. + /// used for the re-encrypted store key. pub fn change_passphrase>( path: P, old_passphrase: &str, diff --git a/src/index/encrypted_stream.rs b/src/index/encrypted_stream.rs index f91b7dd..f37d83d 100644 --- a/src/index/encrypted_stream.rs +++ b/src/index/encrypted_stream.rs @@ -62,7 +62,7 @@ impl AesWriter /// * `key`: The encryption key for the stream cipher. /// * `mac_key`: The authentication key for the MAC. /// * `iv_size`: The size of the initialization vector or nonce for the - /// stream cipher. + /// stream cipher. pub fn new( mut writer: W, key: &[u8], @@ -191,7 +191,7 @@ impl AesReader { /// * `key`: The decryption key for the stream cipher. /// * `mac_key`: The authentication key for the MAC. /// * `iv_size`: The size of the initialization vector or nonce for the - /// streaam cipher. + /// stream cipher. pub fn new( mut reader: R, key: &[u8], @@ -274,7 +274,7 @@ impl AesReader { /// * `reader`: Reader to read encrypted data from /// * `total_length`: The total number of bytes that the reader contains. /// * `mac_length`: The length of the MAC that is stored the file we are - /// reading from. + /// reading from. fn read_until_mac( buffer: &mut [u8], reader: &mut R,