Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored and poljar committed Feb 6, 2025
1 parent 2dc9480 commit 4dbad33
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 41 deletions.
12 changes: 6 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<E: Into<String>>(mut self, event_id: E) -> Self {
self.from_event = Some(event_id.into());
Expand Down
4 changes: 2 additions & 2 deletions src/database/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: AsRef<Path>>(path: P) -> Result<Database>
where
PathBuf: std::convert::From<P>,
Expand All @@ -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<P: AsRef<Path>>(path: P, config: &Config) -> Result<Database>
where
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)>,
Expand Down
4 changes: 2 additions & 2 deletions src/database/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: AsRef<Path>>(path: P) -> Result<Self>
where
PathBuf: std::convert::From<P>,
Expand All @@ -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<P: AsRef<Path>>(path: P, config: &Config) -> Result<Self>
Expand Down
4 changes: 2 additions & 2 deletions src/database/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchBatch> {
let search_result = self.inner.search(term, config)?;

Expand Down
12 changes: 8 additions & 4 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<T> Dummy<T> for Event {
EventType::Message,
"Hello world",
Some("m.text"),
&format!("${}:{}", (0..std::u64::MAX).fake::<u64>(), &domain),
&format!("${}:{}", (0..u64::MAX).fake::<u64>(), &domain),
&format!(
"@{}:{}",
Username(EN).fake::<String>(),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -212,6 +212,7 @@ impl Profile {
}

#[cfg(test)]
#[allow(missing_docs)]
pub static EVENT_SOURCE: &str = r#"{
"content": {
"body": "Test message, msgtype: m.text"
Expand All @@ -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"
Expand All @@ -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",
Expand All @@ -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",
Expand Down
25 changes: 12 additions & 13 deletions src/index/encrypted_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: AsRef<Path>>(
path: P,
passphrase: &str,
Expand Down Expand Up @@ -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)]
Expand All @@ -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<P: AsRef<Path>>(
path: P,
old_passphrase: &str,
Expand Down
6 changes: 3 additions & 3 deletions src/index/encrypted_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<E: StreamCipher + KeyIvInit, M: Mac + NewMac, W: Write> AesWriter<E, M, W>
/// * `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],
Expand Down Expand Up @@ -191,7 +191,7 @@ impl<D: StreamCipher + KeyIvInit, R: Read + Seek + Clone> AesReader<D, R> {
/// * `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<M: Mac + NewMac>(
mut reader: R,
key: &[u8],
Expand Down Expand Up @@ -274,7 +274,7 @@ impl<D: StreamCipher + KeyIvInit, R: Read + Seek + Clone> AesReader<D, R> {
/// * `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,
Expand Down

0 comments on commit 4dbad33

Please sign in to comment.